Файли
openidea/patches/@[email protected]
T
l0ng-ai 54ce048ec9 fix(vim): let af / if work on the right-hand side of a noremap (#7382)
A noremap runs its keys against codemirror-vim's built-in keymap only, and the function text objects were added after every mapclear as user mappings, so nnoremap X daf deleted nothing (same cause as <C-g>u in #7364). af / if are now part of the built-in keymap through the existing vim-core patch, with a placeholder motion the host overrides, and are no longer re-mapped after mapclear.
2026-12-02 12:58:43 +08:00

43 рядки
2.5 KiB
Diff

diff --git a/vim.js b/vim.js
--- a/vim.js
+++ b/vim.js
@@ -236,6 +236,8 @@
{ 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' }},
@@ -248,6 +250,11 @@
{ keys: '<C-t>', type: 'action', action: 'indent', actionArgs: { indentRight: true }, context: 'insert' },
{ keys: '<C-d>', type: 'action', action: 'indent', actionArgs: { indentRight: false }, context: 'insert' },
// Text object motions
+ // OpenIDEA: function text objects; the host defines the motion. Built in, so a noremap's keys reach them.
+ { keys: 'af', type: 'motion', motion: 'openideaFunction', context: 'operatorPending' },
+ { keys: 'if', type: 'motion', motion: 'openideaFunction', motionArgs: { textObjectInner: true }, context: 'operatorPending' },
+ { keys: 'af', type: 'motion', motion: 'openideaFunction', context: 'visual' },
+ { keys: 'if', type: 'motion', motion: 'openideaFunction', motionArgs: { textObjectInner: true }, context: 'visual' },
{ keys: 'a<register>', type: 'motion', motion: 'textObjectManipulation' },
{ keys: 'i<register>', type: 'motion', motion: 'textObjectManipulation', motionArgs: { textObjectInner: true }},
// Search
@@ -2582,6 +2589,8 @@
if (head.sticky == "before") head.ch--;
return head;
},
+ // OpenIDEA: the host overrides this with the function text object.
+ openideaFunction: function(cm, head) { return head; },
textObjectManipulation: function(cm, head, motionArgs, vim) {
// TODO: lots of possible exceptions that can be thrown here. Try da(
// outside of a () block.
@@ -3423,6 +3432,8 @@
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;