feat: Add prompt undo and redo shortcuts#59
Merged
Conversation
Adds Emacs-style undo/redo for the prompt input buffer: - ctrl+- (undo): reverses text changes one step at a time, all the way back to the initial empty buffer. Uses an undo stack capped at 1000 entries. - ctrl+shift+- (redo): restores undone changes one step at a time. New edits clear the redo history. - Pure cursor movement does not create undo entries. - Terminal input parsing handles modifyOtherKeys CSI sequences: \u001B[45;5u and \u001B[27;5;45~ for undo, \u001B[45;6u and \u001B[27;6;45~ for redo, plus raw 0x1F as redo fallback.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变更内容
背景
Prompt 输入目前支持多种编辑快捷键,但缺少常见的撤销和重做能力。终端在不同按键模式下对 Ctrl+- / Ctrl+Shift+- 的上报不同,本次改动在已有 extended key reporting 基础上兼容常见序列,并保持标准 redo 语义:新编辑会清空 redo 历史。
验证