mirror of
https://github.com/VSCodeVim/Vim.git
synced 2024-09-11 12:25:59 +03:00
Remove last instance of TextEditor.delete
This commit is contained in:
parent
05dd48b6ad
commit
86a4ed05a7
@ -2,10 +2,11 @@ import * as vscode from 'vscode';
|
||||
|
||||
import { VimState } from '../../state/vimState';
|
||||
import { Register, RegisterMode } from '../../register/register';
|
||||
import { TextEditor } from '../../textEditor';
|
||||
import * as node from '../node';
|
||||
import { configuration } from '../../configuration/configuration';
|
||||
import { Position } from 'vscode';
|
||||
import { PositionDiff, PositionDiffType } from '../../common/motion/position';
|
||||
import { Range } from '../../common/motion/range';
|
||||
|
||||
export interface IDeleteRangeCommandArguments extends node.ICommandArgs {
|
||||
register?: string;
|
||||
@ -45,9 +46,14 @@ export class DeleteRangeCommand extends node.CommandBase {
|
||||
// Remove leading or trailing newline
|
||||
.replace(/^\r?\n/, '')
|
||||
.replace(/\r?\n$/, '');
|
||||
await TextEditor.delete(vimState.editor, range);
|
||||
|
||||
vimState.recordedState.transformer.addTransformation({
|
||||
type: 'deleteRange',
|
||||
range: new Range(start, end),
|
||||
manuallySetCursorPositions: true,
|
||||
});
|
||||
vimState.cursorStopPosition = start.getLineBegin();
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
|
@ -61,15 +61,6 @@ export class TextEditor {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use DeleteTextTransformation or DeleteTextRangeTransformation instead.
|
||||
*/
|
||||
static async delete(editor: vscode.TextEditor, range: vscode.Range): Promise<boolean> {
|
||||
return editor.edit((editBuilder) => {
|
||||
editBuilder.delete(range);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated. Use ReplaceTextTransformation instead.
|
||||
*/
|
||||
|
@ -32,25 +32,4 @@ suite('text editor', () => {
|
||||
assert.strictEqual(editor.document.lineCount, 1);
|
||||
assert.strictEqual(editor.document.lineAt(0).text, 'Hello Foo Bar');
|
||||
});
|
||||
|
||||
test('delete `Hello`', async () => {
|
||||
const editor = vscode.window.activeTextEditor!;
|
||||
assert.strictEqual(editor.document.lineCount, 1);
|
||||
|
||||
const end = new vscode.Position(0, 5);
|
||||
const range = new vscode.Range(new vscode.Position(0, 0), end);
|
||||
|
||||
await TextEditor.delete(editor, range);
|
||||
assert.strictEqual(editor.document.lineAt(0).text, ' Foo Bar');
|
||||
});
|
||||
|
||||
test('delete the whole line', async () => {
|
||||
const editor = vscode.window.activeTextEditor!;
|
||||
assert.strictEqual(editor.document.lineCount, 1);
|
||||
|
||||
const range = editor.document.lineAt(0).range;
|
||||
|
||||
await TextEditor.delete(editor, range);
|
||||
assert.strictEqual(editor.document.lineAt(0).text, '');
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user