Skip to content

Commit

Permalink
Fixed <C-d> keybindings
Browse files Browse the repository at this point in the history
  • Loading branch information
Chillee committed May 7, 2017
1 parent 508d7f5 commit d733ca4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
{
"key": "ctrl+d",
"command": "extension.vim_ctrl+d",
"when": "editorTextFocus && vim.active && vim.use<C-d> && !inDebugRepl"
"when": "editorTextFocus && vim.active && !inDebugRepl"
},
{
"key": "ctrl+alt+down",
Expand Down
23 changes: 23 additions & 0 deletions src/actions/commands/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3354,6 +3354,29 @@ class ActionOverrideCmdD extends BaseCommand {
}
}

@RegisterAction
class ActionOverrideCmdDInsert extends BaseCommand {
modes = [ModeName.Insert];
keys = ["<D-d>"];
runsOnceForEveryCursor() { return false; }
runsOnceForEachCountPrefix = true;

public async exec(position: Position, vimState: VimState): Promise<VimState> {
// Since editor.action.addSelectionToNextFindMatch uses the selection to
// determine where to add a word, we need to do a hack and manually set the
// selections to the word boundaries before we make the api call.
vscode.window.activeTextEditor!.selections =
vscode.window.activeTextEditor!.selections.map(x => {
const curPos = Position.FromVSCodePosition(x.active);
return new vscode.Selection(curPos.getWordLeft(true),
curPos.getLeft().getCurrentWordEnd(true).getRight());
});
await vscode.commands.executeCommand('editor.action.addSelectionToNextFindMatch');
vimState.allCursors = await allowVSCodeToPropagateCursorUpdatesAndReturnThem();
return vimState;
}
}

@RegisterAction
class ActionOverrideCmdAltDown extends BaseCommand {
modes = [ModeName.Normal, ModeName.Visual];
Expand Down
4 changes: 3 additions & 1 deletion src/mode/modeHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,9 @@ export class ModeHandler implements vscode.Disposable {
key = "<copy>";
}
}

if (key === "<C-d>" && !Configuration.useCtrlKeys) {
key = "<D-d>";
}
this._vimState.cursorPositionJustBeforeAnythingHappened = this._vimState.allCursors.map(x => x.stop);
this._vimState.recordedState.commandList.push(key);

Expand Down

0 comments on commit d733ca4

Please sign in to comment.