Файли
openidea/patches/@[email protected]
T
angelf015таangelf015 c6faf280db fix(vim): support <C-g>u undo breaks in Insert mode (#7364)
An Insert-mode mapping such as `inoremap . .<C-g>u` typed the literal text ".<C-g>u": codemirror-vim has no <C-g>u command and writes unknown <...> keys of a mapping's right-hand side into the document. inoremap only searches the engine's built-in keymap, so the key is added there through a patch to @replit/codemirror-vim-core, bound to an action that isolates the next history event so the text after it starts a new undo group.

Covered by a Vim engine unit test and e2e/vimUndoBreak.spec.ts.

Co-authored-by: angelf015 <[email protected]>
2026-12-02 12:29:12 +08:00

22 рядки
1.2 KiB
Diff

diff --git a/vim.js b/vim.js
--- a/vim.js
+++ b/vim.js
@@ -236,6 +236,8 @@ export function initVim(CM) {
{ keys: '"<register>', type: 'action', action: 'setRegister' },
{ keys: '<C-r><register>', type: 'action', action: 'insertRegister', context: 'insert', isEdit: true },
{ keys: '<C-o>', type: 'action', action: 'oneNormalCommand', context: 'insert' },
+ // OpenIDEA: insert-mode undo break; the host defines this action.
+ { keys: '<C-g>u', type: 'action', action: 'openideaUndoBreak', context: 'insert' },
{ keys: 'zz', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'center' }},
{ keys: 'z.', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'center' }, motion: 'moveToFirstNonWhiteSpaceCharacter' },
{ keys: 'zt', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'top' }},
@@ -3423,6 +3425,8 @@ export function initVim(CM) {
cm.replaceSelection(text);
}
},
+ // OpenIDEA: the host overrides this with the undo-break implementation.
+ openideaUndoBreak: function() {},
oneNormalCommand: function(cm, actionArgs, vim) {
exitInsertMode(cm, true);
vim.insertModeReturn = true;