Skip to content
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

Fixes #1749: <D-d> in insert mode doesn't work when the word isn't by itself #1748

Merged
merged 2 commits into from
May 25, 2017
Merged
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
16 changes: 13 additions & 3 deletions src/actions/commands/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3148,10 +3148,20 @@ class ActionOverrideCmdD extends BaseCommand {
// 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 => {
vscode.window.activeTextEditor!.selections.map((x, idx) => {
const curPos = Position.FromVSCodePosition(x.active);
return new vscode.Selection(curPos.getWordLeft(true),
curPos.getLeft().getCurrentWordEnd(true).getRight());
if (idx === 0) {
return new vscode.Selection(curPos.getWordLeft(false),
curPos.getLeft().getCurrentWordEnd(true).getRight());
} else {
// Since we're adding the selections ourselves, we need to make sure
// that our selection is actually over what our original word is
const matchWordPos = Position.FromVSCodePosition(vscode.window.activeTextEditor!.selections[0].active);
const matchWordLength = matchWordPos.getLeft().getCurrentWordEnd(true).getRight().character -
matchWordPos.getWordLeft(false).character;
const wordBegin = curPos.getLeftByCount(matchWordLength);
return new vscode.Selection(wordBegin, curPos);
}
});
await vscode.commands.executeCommand('editor.action.addSelectionToNextFindMatch');
vimState.allCursors = await allowVSCodeToPropagateCursorUpdatesAndReturnThem();
Expand Down