Skip to content

Fix split-view highlight desync (#71) - #94

Merged
shardulm94 merged 1 commit into
masterfrom
fix/split-view-highlight-desync-71
Jun 23, 2026
Merged

shardulm94 merged 1 commit into
masterfrom
fix/split-view-highlight-desync-71

Conversation

@shardulm94

Copy link
Copy Markdown
Owner

Summary

Fixes the highlight half of #71. When the same file is open in multiple split panes, editing one pane only re-highlighted the active editor, leaving the other pane's trailing-space decorations stale:

  • Add a space in the right pane → left pane never showed the highlight.
  • Delete the space in the left pane → right pane kept a leftover red sliver.

Root cause: onDidChangeTextDocument only called highlight() on window.activeTextEditor. Decorations are per-TextEditor, so the other visible editor for the same document was never refreshed. The fix re-highlights every visible editor showing the changed document.

Note: the other half of #71 (trim-on-save not firing in split view) was already fixed by the #76 refactor. This PR adds a regression test for that path too, but the behavioral fix here is for the highlight desync.

Tests

Two new split-view regression tests (issue71.test.ts, issue71-highlight.test.ts), both verified to fail without the corresponding fix and pass with it. Full suite: 15 passing.

Decorations can't be read back through the VS Code API, so TrailingSpaces retains the ranges it applies per editor (WeakMap) and exposes a narrow getHighlightedRanges fetcher. The integration-test hooks (settings + getHighlightedRanges) are returned from activate() only outside production (gated on extensionMode), so no internal objects are exposed on the production API surface.

🤖 Generated with Claude Code

When the same document was open in multiple split panes, editing one
pane only re-highlighted the active editor, leaving the other pane's
trailing-space decorations stale (missing highlights, or a leftover red
sliver after a deletion). Re-highlight every visible editor showing the
changed document instead of just the active one.

Add regression tests covering split view for both trim-on-save and
highlight sync. Decorations cannot be read back through the VSCode API,
so TrailingSpaces retains the ranges it applies per editor and exposes a
narrow getHighlightedRanges fetcher. The integration test hooks
(settings + getHighlightedRanges) are returned from activate() only
outside production (gated on extensionMode), so no internal objects are
handed out on the production API surface.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@shardulm94
shardulm94 force-pushed the fix/split-view-highlight-desync-71 branch from 20b641d to 6162e0e Compare June 20, 2026 21:37
@shardulm94
shardulm94 merged commit 6722bee into master Jun 23, 2026
6 checks passed
@shardulm94
shardulm94 deleted the fix/split-view-highlight-desync-71 branch June 23, 2026 00:59
@shardulm94 shardulm94 mentioned this pull request Jun 23, 2026
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