Skip to content

fix(selection): clear editor highlight when selection chip is deleted - #93

Merged
luoxuanzao merged 1 commit into
mainfrom
fix/selection-chip-highlight-cleanup
Oct 10, 2026
Merged

luoxuanzao merged 1 commit into
mainfrom
fix/selection-chip-highlight-cleanup

Conversation

@luoxuanzao

Copy link
Copy Markdown
Member

Summary

Clicking the X on a captured selection chip removes the token from the composer input. SelectionController.reconcileToken() noticed this and dropped the stored selection, but it did not clear the mock highlight shown in the editor (or the preview CSS highlight). The highlight would linger because storedSelection was already null by the time any cleanup ran.

Fix by calling clearHighlight() before nulling storedSelection.

Test plan

  • npm test -- tests/unit/features/chat/controllers/selection-controller.test.ts passes (30 tests).
  • Added/updated unit tests assert that both edit-mode (hideSelectionHighlight) and preview-mode (CSS.highlights.delete) highlights are cleaned up when the chip token is removed.
  • npm run typecheck passes.
  • Built and deployed locally to verify the fix in Obsidian.

Clicking the X on a captured selection chip removes the token from the
composer input. The SelectionController noticed this and dropped the stored
selection, but it forgot to clear the mock highlight shown in the editor
(or preview CSS highlight). The highlight would linger because storedSelection
was already null by the time any cleanup ran.

Call clearHighlight() before nulling storedSelection so the CM6/CSS highlight
is removed together with the chip.
@luoxuanzao
luoxuanzao merged commit e95e90e into main Oct 10, 2026
9 checks passed
@luoxuanzao
luoxuanzao deleted the fix/selection-chip-highlight-cleanup branch October 10, 2026 15:04
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.

1 participant