Skip to content

fix(terminal): stop keyword highlight flicker on Enter - #2805

Merged
cursor[bot] merged 5 commits into
mainfrom
cursor/fix-keyword-highlight-enter-flicker-0416
Aug 7, 2026
Merged

fix(terminal): stop keyword highlight flicker on Enter#2805
cursor[bot] merged 5 commits into
mainfrom
cursor/fix-keyword-highlight-enter-flicker-0416

Conversation

@binaricat

@binaricat binaricat commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Summary

With keyword highlighting enabled, pressing Enter (which scrolls the terminal) could flash existing highlights. The earlier approach special-cased Enter to skip scroll pruning; that fights real scrolling and is the wrong model.

This PR ports the architecture from community PR #2348 (mam15mon): persist nearby keyword decorations across scroll, scan only newly exposed rows, and bound retention so broad rules cannot grow unbounded. Continuously pressing Enter is treated as real scroll. Also keeps an atomic cursor-line decoration swap so current-line + delimiter highlights do not clear-before-create flash.

Type of Change

  • Bug fix
  • New feature
  • Refactor / code cleanup
  • Documentation update
  • Build / CI change
  • Other (please describe):

Related Issue (optional)

Closes #2784
Related to #2348

Changes Made

  • Persist keyword decorations across user/Enter-driven scroll instead of prune-on-scroll
  • Incremental processScrollViewport for newly exposed rows (immediate scroll refresh)
  • O(1) marker line-offset sync when possible; rebuild only on structural invalidation
  • Retention caps: 20 viewports / max 1200 matched lines (xtermPerformance.ts)
  • Preserve write-burst / large-output / Enter write-path protections
  • Cursor-line highlight: register new decorations before disposing old ones
  • Credit: mam15mon / [codex] Persist terminal highlights across scrolling #2348 for the persistence model

Screenshots / Demo

N/A (terminal highlight stability while scrolling / pressing Enter)

Testing

  • I have tested these changes locally (npm run dev)
  • Linting passes (npm run lint)
  • Tests pass (npm test) — keywordHighlight + cursorLineHighlight (61)
  • Generated capability tool specs are updated when applicable (npm run generate:capability-tools)
  • No new console errors or warnings, if this affects app behavior

Checklist

  • My code follows the existing project style
  • I have added or updated relevant documentation
  • I have not introduced any breaking changes (or I have described them above)

Performance notes

  • No full multi-viewport rescan on every scroll; only newly exposed rows
  • Persistent decorations are capped (20 viewports / ≤1200 lines)
  • Large-output / write-burst degradation paths unchanged
Open in Web Open in Cursor 

Idle Enter was misclassified as user scroll so overscan decorations were
pruned before writeParsed cancel (Ubuntu RTT). Also swap cursor-line
decorations atomically to avoid clear-before-create flash (fixes #2784).

Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com>
@binaricat binaricat added the automation:codex-loop Own/bot PR waiting on Codex review↔fix loop label Aug 7, 2026
@binaricat

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

While enterInputPending blocked scroll-prune, viewport scrolls were also
ignored with no dirty mark. Mark dirty during the window and trigger a
write refresh when Enter protection clears.

Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com>
@binaricat

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

Replace Enter scroll-skip band-aid with mam15mon/#2348 persistence:
keep decorations across scroll, sync only newly exposed rows, bound
retention (~20 viewports / max 1200). Keep Enter write-path protections
and cursor-line atomic swap. Continuous Enter may scroll; prune-on-scroll
is gone.

Co-authored-by: mam15mon <mam15mon@users.noreply.github.com>
Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com>
@binaricat

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

Keep Enter/write deferred pruning intact by pruning the retention cap
only after scroll viewport indexing, not on every decoration apply.

Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com>
@binaricat

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

Overlapping scroll only scanned newly exposed rows then cleared the whole
viewport dirty set, which could drop in-place redraw work when scroll
outranked a pending write refresh. Rescan write-dirtied overlap lines and
only clear dirty for ranges that were actually processed.

Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com>
@binaricat

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@cursor
cursor Bot marked this pull request as ready for review August 7, 2026 10:25
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@cursor
cursor Bot merged commit b7979e0 into main Aug 7, 2026
35 checks passed
@netcatty-bot netcatty-bot removed the automation:codex-loop Own/bot PR waiting on Codex review↔fix loop label Aug 7, 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.

[Bug] 开启关键词高亮的情况下,按回车,高亮的关键词还是会闪烁

3 participants