From 761d7590e4deac1636e724a048db80b4e8332f1e Mon Sep 17 00:00:00 2001 From: Kamil Laskowski Date: Thu, 26 Jun 2025 20:48:08 +0200 Subject: [PATCH] gI goToImplementation --- src/actions/commands/actions.ts | 25 ++++++++++++----------- src/actions/commands/insert.ts | 2 -- test/mode/modeNormal.test.ts | 35 +++++++++++++++++---------------- 3 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/actions/commands/actions.ts b/src/actions/commands/actions.ts index d05d77dd743..7f9dba8af49 100644 --- a/src/actions/commands/actions.ts +++ b/src/actions/commands/actions.ts @@ -939,6 +939,20 @@ class GoToDefinition extends BaseCommand { } } } +@RegisterAction +class GoToImplementation extends BaseCommand { + modes = [Mode.Normal]; + keys = ['g', 'I']; + override isJump = true; + + public override async exec(position: Position, vimState: VimState): Promise { + await vscode.commands.executeCommand('editor.action.goToImplementation'); + + if (vimState.editor === vscode.window.activeTextEditor) { + vimState.cursorStopPosition = vimState.editor.selection.start; + } + } +} @RegisterAction class CommandOpenLink extends BaseCommand { @@ -1009,17 +1023,6 @@ export class CommandInsertAtFirstCharacter extends BaseCommand { } } -@RegisterAction -export class CommandInsertAtLineBegin extends BaseCommand { - modes = [Mode.Normal]; - keys = ['g', 'I']; - - public override async exec(position: Position, vimState: VimState): Promise { - await vimState.setCurrentMode(Mode.Insert); - vimState.cursorStopPosition = vimState.cursorStartPosition = position.getLineBegin(); - } -} - @RegisterAction export class CommandInsertAfterCursor extends BaseCommand { modes = [Mode.Normal]; diff --git a/src/actions/commands/insert.ts b/src/actions/commands/insert.ts index 02e0586afba..c757de2a34e 100644 --- a/src/actions/commands/insert.ts +++ b/src/actions/commands/insert.ts @@ -19,7 +19,6 @@ import { CommandInsertAtCursor, CommandInsertAtFirstCharacter, CommandInsertAtLastChange, - CommandInsertAtLineBegin, CommandInsertAtLineEnd, CommandInsertNewLineAbove, CommandInsertNewLineBefore, @@ -75,7 +74,6 @@ export class CommandEscInsertMode extends BaseCommand { (a) => a instanceof CommandInsertAtCursor || a instanceof CommandInsertAfterCursor || - a instanceof CommandInsertAtLineBegin || a instanceof CommandInsertAtLineEnd || a instanceof CommandInsertAtFirstCharacter || a instanceof CommandInsertAtLastChange, diff --git a/test/mode/modeNormal.test.ts b/test/mode/modeNormal.test.ts index 9b94e4148a8..cc930adef37 100755 --- a/test/mode/modeNormal.test.ts +++ b/test/mode/modeNormal.test.ts @@ -1636,23 +1636,24 @@ suite('Mode Normal', () => { }); }); - suite('gI', () => { - newTest({ - title: 'gI enters insert mode at start of line', - start: [' o|ne'], - keysPressed: 'gItest', - end: ['test| one'], - endMode: Mode.Insert, - }); - - newTest({ - title: '[count]gI', - start: [' o|ne'], - keysPressed: '3gIab', - end: ['ababa|b one'], - endMode: Mode.Normal, - }); - }); + // TODO: tests for goToImplementation + // suite('gI', () => { + // newTest({ + // title: 'gI enters insert mode at start of line', + // start: [' o|ne'], + // keysPressed: 'gItest', + // end: ['test| one'], + // endMode: Mode.Insert, + // }); + + // newTest({ + // title: '[count]gI', + // start: [' o|ne'], + // keysPressed: '3gIab', + // end: ['ababa|b one'], + // endMode: Mode.Normal, + // }); + // }); suite('gi', () => { newTest({