Skip to content

Keep undo history separate for each language - #456

Open
Chingyong0905 wants to merge 1 commit into
sysprog21:mainfrom
Chingyong0905:fix-language-undo-v4
Open

Chingyong0905 wants to merge 1 commit into
sysprog21:mainfrom
Chingyong0905:fix-language-undo-v4

Conversation

@Chingyong0905

@Chingyong0905 Chingyong0905 commented Oct 23, 2026 •

Copy link
Copy Markdown

Switching languages can make Undo restore another language's deleted text. Keep up to 200 edits per language for Python, JavaScript, C, C++ and Java. Language switches record no edit and restore the selected language's buffer and history.

Typing, paste, cut, drop, composition, indentation, bracket edits, comment toggling and starter restores use the page history. Undo and redo restore the selection bounds and direction. Programmatic edits assign the buffer directly and use the existing input path for painting, replay and code_update. Restore works on the first press, including without native editing commands; the old confirmation and newline workaround are removed.

Whitespace separates typing groups. History notifications during IME composition remain with the input method; the committed composition is one edit. The tests cover both composition history input types and both cancelable and input-only history paths.

Rebased onto main at 7c50276. All 351 related tests pass locally with no skips. Commit 88ce69c passes the browser, portable, Rust and audit checks in [upstream CI](https://github.com/sysprog21/codetrial/actions/runs/40118611094). The IME checks use synthetic events.

Native Edit/context-menu availability still follows the browser's own history. Cancelable history events are intercepted; input-only notifications are repaired afterward. This does not guarantee that native undo never executes or that native Redo is enabled.

Python after Undo
Python after Undo: BBB is restored.

JavaScript after Undo
JavaScript after Undo: 222 is restored.

Closes #365

cubic-dev-ai[bot]

This comment was marked as resolved.

Comment thread web/interview.js Outdated
Comment thread web/interview.js Outdated
Comment thread web/interview.js Outdated
Comment thread web/editor-history.js
jserv

This comment was marked as outdated.

Comment thread web/interview.js Outdated
Comment thread web/interview.js Outdated

@jserv jserv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before asking someone to review, you MUST resolve any regressions flagged by GitHub Actions.

Comment thread tests/browser/editor-language-history.test.js Outdated

@jserv jserv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebase latest main branch and resolve conflicts.

Keep editor history per language so Undo cannot replay another buffer.
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.

Switching programming languages causes undo to restore text in the wrong language

3 participants