Skip to content

fix(caret): misalignment issue when switching between carets (@byseif21) #6642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

byseif21
Copy link
Contributor

@byseif21 byseif21 commented Jun 18, 2025

Description

fixes a caret misalignment issue that occurred when switching between caret styles (e.g., from block/outline/underline to line caret).

Bug:

When switching caret styles, the line caret could retain the width from the previous style (e.g., block), causing it to appear visually incorrect until the next input.

Root Cause:

  • The caret's inline width was not reset when changing styles, so the new style inherited the old dimensions.
  • updatePosition() was called before the style was fully applied, leading to incorrect positioning.

Fix

  • Added a subscribe listener in caret.ts for the "caretStyle" event.

  • When the caret style changes:

    • The caret's inline width is reset:

      caret.style.width = "";
    • Its position is immediately recalculated with:

      updatePosition(true);

@monkeytypegeorge monkeytypegeorge added the frontend User interface or web stuff label Jun 18, 2025
byseif21 added 3 commits June 19, 2025 03:06
- Listen for 'caretStyle' changes via ConfigEvent in caret.ts.
- On caret style change, reset caret's inline width and force a position recalculation.
@byseif21
Copy link
Contributor Author

  • We could also use $(caret).css("width", ""); in updatePosition(); to always clear caret width to prevent line caret width from inheriting
    but i had some doubt about it being always called while we will only need it acutely once when switching between the carets so lmkwdyt

@byseif21 byseif21 changed the title impr(caret): correct initial line caret position when switching from block caret (@byseif21) fix(caret): misalignment issue when switching between carets (@byseif21) Jun 20, 2025
@byseif21 byseif21 marked this pull request as ready for review June 20, 2025 15:19
@github-actions github-actions bot added the waiting for review Pull requests that require a review before continuing label Jun 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend User interface or web stuff waiting for review Pull requests that require a review before continuing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants