mirror of
https://github.com/VSCodeVim/Vim.git
synced 2024-09-20 16:48:42 +03:00
<C-u> in insert mode deletes line break when used at start of line
Fixes #6429
This commit is contained in:
parent
594b308597
commit
057cfc58ed
@ -536,13 +536,20 @@ class CommandCtrlUInInsertMode extends BaseCommand {
|
||||
keys = ['<C-u>'];
|
||||
|
||||
public async exec(position: Position, vimState: VimState): Promise<void> {
|
||||
const start = position.isInLeadingWhitespace(vimState.document)
|
||||
? position.getLineBegin()
|
||||
: position.getLineBeginRespectingIndent(vimState.document);
|
||||
let start: Position;
|
||||
if (position.character === 0) {
|
||||
start = position.getLeftThroughLineBreaks(true);
|
||||
} else if (position.isInLeadingWhitespace(vimState.document)) {
|
||||
start = position.getLineBegin();
|
||||
} else {
|
||||
start = position.getLineBeginRespectingIndent(vimState.document);
|
||||
}
|
||||
|
||||
vimState.recordedState.transformer.addTransformation({
|
||||
type: 'deleteRange',
|
||||
range: new Range(start, position),
|
||||
});
|
||||
|
||||
vimState.cursorStopPosition = start;
|
||||
vimState.cursorStartPosition = start;
|
||||
}
|
||||
|
@ -131,25 +131,38 @@ suite('Mode Insert', () => {
|
||||
end: ['foo|bar'],
|
||||
});
|
||||
|
||||
newTest({
|
||||
title: '<C-u> deletes to start of line',
|
||||
start: ['text |text'],
|
||||
keysPressed: 'i<C-u>',
|
||||
end: ['|text'],
|
||||
});
|
||||
suite('<C-u>', () => {
|
||||
newTest({
|
||||
title: '<C-u> deletes to start of line',
|
||||
start: ['text |text'],
|
||||
keysPressed: 'i<C-u>',
|
||||
end: ['|text'],
|
||||
endMode: Mode.Insert,
|
||||
});
|
||||
|
||||
newTest({
|
||||
title: 'Can handle <C-u> on leading characters',
|
||||
start: ['{', ' foo: |true', '}'],
|
||||
keysPressed: 'i<C-u>',
|
||||
end: ['{', ' |true', '}'],
|
||||
});
|
||||
newTest({
|
||||
title: 'Can handle <C-u> on leading characters',
|
||||
start: ['{', ' foo: |true', '}'],
|
||||
keysPressed: 'i<C-u>',
|
||||
end: ['{', ' |true', '}'],
|
||||
endMode: Mode.Insert,
|
||||
});
|
||||
|
||||
newTest({
|
||||
title: 'Can handle <C-u> on leading whitespace',
|
||||
start: ['{', ' |true', '}'],
|
||||
keysPressed: 'i<C-u>',
|
||||
end: ['{', '|true', '}'],
|
||||
newTest({
|
||||
title: 'Can handle <C-u> on leading whitespace',
|
||||
start: ['{', ' |true', '}'],
|
||||
keysPressed: 'i<C-u>',
|
||||
end: ['{', '|true', '}'],
|
||||
endMode: Mode.Insert,
|
||||
});
|
||||
|
||||
newTest({
|
||||
title: '<C-u> at start of line deletes line break',
|
||||
start: ['one', '|two', 'three'],
|
||||
keysPressed: 'i<C-u>',
|
||||
end: ['one|two', 'three'],
|
||||
endMode: Mode.Insert,
|
||||
});
|
||||
});
|
||||
|
||||
test('Correctly places the cursor after deleting the previous line break', async () => {
|
||||
|
Loading…
Reference in New Issue
Block a user