Skip to content

feat: Add live character count display to the editor#147

Open
vedikapatil2410 wants to merge 2 commits into
suresh1319:masterfrom
vedikapatil2410:Characters-count
Open

feat: Add live character count display to the editor#147
vedikapatil2410 wants to merge 2 commits into
suresh1319:masterfrom
vedikapatil2410:Characters-count

Conversation

@vedikapatil2410
Copy link
Copy Markdown

Summary

Fixes #<144> (replace with the actual issue number)

Added a live character counter in the editor footer that updates dynamically as the user types.

Changes Made

  • src/components/Editor.js: Added charCount state using useState
  • Updated the editor.on('change') handler to track character count
  • Rendered a styled footer below the editor showing Characters: <count>

How to Test

  1. Open any room and select a file in the editor
  2. Start typing code
  3. The footer should show the live character count updating in real time

##Screenshot
Screenshot 2026-06-01 125942

Type of Change

  • New feature (non-breaking change which adds functionality)

@vedikapatil2410
Copy link
Copy Markdown
Author

Hi @suresh1319 kindly review the PR for the task

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a live “Characters: N” counter to the collaborative CodeMirror editor UI so users can see the current document size while typing.

Changes:

  • Introduced charCount state in Editor and update it from the CodeMirror change event.
  • Rendered a footer below the editor textarea showing the current character count.
  • Updated package-lock.json (appears to be lockfile metadata churn, not feature-related).

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/components/Editor.js Tracks editor content length and displays a live character-count footer.
package-lock.json Lockfile metadata changes ("peer": true moved/removed/added across packages).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/components/Editor.js
@vedikapatil2410
Copy link
Copy Markdown
Author

vedikapatil2410 commented Jun 2, 2026

@suresh1319 Thanks for the review. I updated the character count initialization so it is reset/populated when the editor is recreated and the document syncs, preventing the previous file's count from being displayed after switching files.

@entelligence-ai-pr-reviews
Copy link
Copy Markdown
Contributor

EntelligenceAI PR Summary

Fixes character count state initialization in Editor.js to correctly reflect content length on sync rather than only on subsequent editor changes.

  • Updated handleSync callback to set charCount using ytext.length immediately upon Yjs sync
  • Added charCount initialization to initialContent.length after injecting initial content into the Yjs document
  • Removed a minor blank line after editorRef.current assignment

Confidence Score: 5/5 - Safe to Merge

Safe to merge — this PR correctly fixes character count state initialization in Editor.js by setting charCount via ytext.length in the handleSync callback and initialContent.length after injecting initial content into the Yjs document, ensuring the count reflects actual content immediately rather than only after subsequent edits. The changes are minimal, focused, and logically sound: both code paths that establish initial document state are now updated consistently. No new issues were introduced, and the removed blank line after editorRef.current assignment is purely cosmetic with zero runtime impact.

Key Findings:

  • handleSync now correctly reads ytext.length upon Yjs sync, eliminating a stale-zero initialization bug where charCount would show 0 for pre-existing content until the user made an edit.
  • The charCount initialization to initialContent.length after injecting content into the Yjs document is consistent with the sync fix, ensuring both the collaborative-sync and the initial-load code paths correctly reflect document state.
  • The scope of the change is narrow and well-contained within Editor.js, reducing regression risk — no shared utilities, APIs, or data structures are touched.
  • No review comments were generated and heuristic analysis found zero issues of any severity, supporting a clean merge.
Files requiring special attention
  • Editor.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants