Skip to content

Harden custom caret plugin for multiple editors#16

Closed
Codex wants to merge 2 commits intosmooth-caretfrom
codex/sub-pr-13-again
Closed

Harden custom caret plugin for multiple editors#16
Codex wants to merge 2 commits intosmooth-caretfrom
codex/sub-pr-13-again

Conversation

@Codex
Copy link
Contributor

@Codex Codex AI commented Feb 21, 2026

Greptile flagged two risks in the new animated caret: module-level state breaks multiple editors and plugin silently fails if the editor DOM parent is missing.

  • Scoped instances: track caret elements per EditorView so setCaretStyle updates all views and cleanup is per-instance.
  • Init guard: bail with a warning when no parent container exists instead of silently failing.

Example:

const caretInstances = new Set<{ view: EditorView; el: HTMLElement }>();

export function setCaretStyle(style: CaretStyle) {
  caretStyle = style;
  caretInstances.forEach(({ view, el }) => updateCaret(view, el));
}

view(view) {
  const parent = view.dom.parentElement;
  if (!parent) {
    console.warn("caretPlugin: editor has no parent element; skipping custom caret");
    return {};
  }
  // ...
}

@Codex Codex AI changed the title [WIP] Add smooth animated caret with line and underline styles Harden custom caret plugin for multiple editors Feb 21, 2026
@Codex Codex AI requested a review from usamaasfar February 21, 2026 18:16
@usamaasfar usamaasfar closed this Feb 21, 2026
@usamaasfar usamaasfar deleted the codex/sub-pr-13-again branch February 21, 2026 18:17
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