Skip to content

#1996 Restore the macro-block caret synchronously after a live repaint - #1999

Merged
TimothyLuke merged 1 commit into
TimothyLuke:masterfrom
LarryThiessen:fix-1996-caret-sync-restore
Aug 22, 2026
Merged

#1996 Restore the macro-block caret synchronously after a live repaint#1999
TimothyLuke merged 1 commit into
TimothyLuke:masterfrom
LarryThiessen:fix-1996-caret-sync-restore

Conversation

@LarryThiessen

Copy link
Copy Markdown
Contributor

Fixes #1996

Problem

RefreshMacroEditorColoredText repaints with SetText (caret parks at the end) and restored the caret only via a deferred C_Timer.After(0) — so a frame rendered with the caret and scroll view at the end of the bottom line before it moved back (visible flick every live repaint), a fast follow-up key acted at the end, and the unconditional deferred restore could yank the caret to a stale position after a newer keystroke.

Fix (1 file, Editor.lua)

Restore the caret synchronously right after SetText (IndentationLib's long-standing SetText+SetCursorPosition-in-one-go approach). Keep the deferred restore only as a backstop: scheduled only if the immediate restore visibly did not take, and it re-checks the text is still the text it was computed for before touching the caret. Colouring logic untouched.

Verified

In-game: no flick; fast typing/deleting stays put; the earlier #1959 behaviours (Enter row push, Backspace through commas, top-left Backspace) unaffected. luac -p clean.

🤖 Generated with Claude Code

…live repaint

RefreshMacroEditorColoredText repaints the coloured text with SetText,
which parks the caret at the end, and only restored it via a deferred
C_Timer.After(0) -- so a frame rendered with the caret (and the scroll
view chasing it) at the end of the bottom line before it moved back: a
visible flick on every live repaint, and a fast follow-up key acted at
the end of the text. An unconditional deferred restore could also yank
the caret back to a stale position one frame after a newer keystroke.

Restore the caret synchronously right after SetText (the same
SetText+SetCursorPosition-in-one-go approach IndentationLib has used for
years). Keep the deferred restore only as a backstop: scheduled only if
the immediate restore visibly did not take, and it re-checks that the
text is still the text it was computed for before touching the caret.
Colouring logic is untouched.

Fixes TimothyLuke#1996

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@TimothyLuke
TimothyLuke merged commit 805bb95 into TimothyLuke:master Aug 22, 2026
1 check passed
@LarryThiessen
LarryThiessen deleted the fix-1996-caret-sync-restore branch August 22, 2026 23:23
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] Macro block caret visibly jumps to the end of the last row and back on every live repaint; fast typing/deleting can land at the wrong spot

2 participants