mirror of
https://github.com/VSCodeVim/Vim.git
synced 2024-09-19 16:18:45 +03:00
Merge pull request #1644 from Chillee/1256
Fixes #1256 and #394: Fixes delete key and adds functionality
This commit is contained in:
commit
e38c4f67e8
@ -117,7 +117,7 @@
|
||||
{
|
||||
"key": "Delete",
|
||||
"command": "extension.vim_delete",
|
||||
"when": "editorTextFocus && vim.active && vim.mode == 'Normal' && !inDebugRepl"
|
||||
"when": "editorTextFocus && vim.active && !inDebugRepl"
|
||||
},
|
||||
{
|
||||
"key": "tab",
|
||||
|
@ -2240,17 +2240,18 @@ class ActionDeleteCharWithDeleteKey extends BaseCommand {
|
||||
runsOnceForEachCountPrefix = true;
|
||||
canBeRepeatedWithDot = true;
|
||||
|
||||
public async exec(position: Position, vimState: VimState): Promise<VimState> {
|
||||
// N<del> is a no-op in Vim
|
||||
if (vimState.recordedState.count !== 0) {
|
||||
return vimState;
|
||||
}
|
||||
|
||||
const state = await new operator.DeleteOperator(this.multicursorIndex).run(vimState, position, position);
|
||||
|
||||
state.currentMode = ModeName.Normal;
|
||||
|
||||
return state;
|
||||
public async execCount(position: Position, vimState: VimState): Promise<VimState> {
|
||||
// If <del> has a count in front of it, then <del> deletes a character
|
||||
// off the count. Therefore, 100<del>x, would apply 'x' 10 times.
|
||||
// http://vimdoc.sourceforge.net/htmldoc/change.html#<Del>
|
||||
if (vimState.recordedState.count !== 0) {
|
||||
vimState.recordedState.count = Math.floor(vimState.recordedState.count / 10);
|
||||
vimState.recordedState.actionKeys = vimState.recordedState.count.toString().split("");
|
||||
vimState.recordedState.commandList = vimState.recordedState.count.toString().split("");
|
||||
this.isCompleteAction = false;
|
||||
return vimState;
|
||||
}
|
||||
return await new ActionDeleteChar().execCount(position, vimState);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -138,15 +138,12 @@ export class DeleteOperator extends BaseOperator {
|
||||
}
|
||||
|
||||
public async run(vimState: VimState, start: Position, end: Position, yank = true): Promise<VimState> {
|
||||
await this.delete(start, end, vimState.currentMode, vimState.effectiveRegisterMode(), vimState, yank);
|
||||
let newPos = await this.delete(start, end, vimState.currentMode, vimState.effectiveRegisterMode(), vimState, yank);
|
||||
|
||||
vimState.currentMode = ModeName.Normal;
|
||||
|
||||
/*
|
||||
vimState.cursorPosition = result;
|
||||
vimState.cursorStartPosition = result;
|
||||
*/
|
||||
|
||||
if (vimState.currentMode === ModeName.Visual) {
|
||||
vimState.desiredColumn = newPos.character;
|
||||
}
|
||||
return vimState;
|
||||
}
|
||||
}
|
||||
@ -232,12 +229,13 @@ export class ShiftYankOperatorVisual extends BaseOperator {
|
||||
vimState.currentRegisterMode = RegisterMode.LineWise;
|
||||
|
||||
return await new YankOperator().run(vimState, start, end);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@RegisterAction
|
||||
export class DeleteOperatorXVisual extends BaseOperator {
|
||||
public keys = ["x"];
|
||||
public keys = ["x", "<Del>"];
|
||||
public modes = [ModeName.Visual, ModeName.VisualLine];
|
||||
|
||||
public async run(vimState: VimState, start: Position, end: Position): Promise<VimState> {
|
||||
|
@ -62,10 +62,10 @@ suite("Mode Normal", () => {
|
||||
});
|
||||
|
||||
newTest({
|
||||
title: "Can handle 'N<Del>', which should be a no-op",
|
||||
start: ['te|xt'],
|
||||
keysPressed: '2<Del>',
|
||||
end: ["te|xt"],
|
||||
title: "Can handle '<Del>' with counts, which removes the last character of the count",
|
||||
start: ['|text'],
|
||||
keysPressed: '10<Del>x',
|
||||
end: ["|ext"],
|
||||
});
|
||||
|
||||
newTest({
|
||||
|
Loading…
Reference in New Issue
Block a user