Skip to content

gI goToImplementation #9688

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions src/actions/commands/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
await vscode.commands.executeCommand('editor.action.goToImplementation');

if (vimState.editor === vscode.window.activeTextEditor) {
vimState.cursorStopPosition = vimState.editor.selection.start;
}
}
}

@RegisterAction
class CommandOpenLink extends BaseCommand {
Expand Down Expand Up @@ -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<void> {
await vimState.setCurrentMode(Mode.Insert);
vimState.cursorStopPosition = vimState.cursorStartPosition = position.getLineBegin();
}
}

@RegisterAction
export class CommandInsertAfterCursor extends BaseCommand {
modes = [Mode.Normal];
Expand Down
2 changes: 0 additions & 2 deletions src/actions/commands/insert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
CommandInsertAtCursor,
CommandInsertAtFirstCharacter,
CommandInsertAtLastChange,
CommandInsertAtLineBegin,
CommandInsertAtLineEnd,
CommandInsertNewLineAbove,
CommandInsertNewLineBefore,
Expand Down Expand Up @@ -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,
Expand Down
35 changes: 18 additions & 17 deletions test/mode/modeNormal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Esc>',
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<Esc>',
// end: ['ababa|b one'],
// endMode: Mode.Normal,
// });
// });

suite('gi', () => {
newTest({
Expand Down