[desktop] Fix module-level state and silent failure in caret plugin#14
Merged
usamaasfar merged 2 commits intosmooth-caretfrom Feb 21, 2026
Merged
[desktop] Fix module-level state and silent failure in caret plugin#14usamaasfar merged 2 commits intosmooth-caretfrom
usamaasfar merged 2 commits intosmooth-caretfrom
Conversation
Co-authored-by: usamaasfar <42825498+usamaasfar@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add smooth animated caret with line and underline styles
[desktop] Fix module-level state and silent failure in caret plugin
Feb 21, 2026
usamaasfar
added a commit
that referenced
this pull request
Feb 21, 2026
* Add smooth animated caret with line and underline styles - Custom ProseMirror plugin renders a virtual caret (hides native) - Smooth 60ms CSS transition between positions while typing - Blink pauses while typing, resumes 0.5s after last keystroke - Line and underline styles switchable via Appearance > Cursor menu - Style persisted to localStorage and restored on startup Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * [desktop] Fix module-level state and silent failure in caret plugin (#14) * Initial plan * Fix module-level state and silent failure in caret plugin Co-authored-by: usamaasfar <42825498+usamaasfar@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: usamaasfar <42825498+usamaasfar@users.noreply.github.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
caret.tsused module-levelactiveView/activeElvariables, meaning each new editor instance silently overwrote the previous ones. Additionally, missingparentElementwas swallowed via optional chaining, producing an invisible, never-appended caret element with no error surfaced.Changes
activeView/activeElwithMap<EditorView, HTMLElement>;setCaretStylenow iterates all active instances instead of clobbering on each mountview.dom.parentElement?.appendChild(el)with a guard that throws an actionable error, so a mis-mounted editor fails loudly at init rather than silently rendering nothingdestroy()now callsactiveInstances.delete(view)(keyed deletion), replacing the previous null-assignment that broke any remaining instances💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.
Greptile Summary
Fixed critical bugs in caret plugin by replacing module-level singleton state with a
Map<EditorView, HTMLElement>to properly track multiple editor instances, and replaced silent optional chaining failure with explicit error when parent element is missing.Key improvements:
setCaretStylenow updates all active editors instead of only the most recent onedestroy()uses keyed deletion from Map instead of nulling shared stateConfidence Score: 5/5
Important Files Changed
Last reviewed commit: ba5fb5b