mirror of
https://github.com/VSCodeVim/Vim.git
synced 2024-09-17 15:17:18 +03:00
Fix gp
when pasting more than three lines (#4247)
* Fix `gp` when pasting more than three lines Respect added lines count when creating new PositionDiff. Fixes #4246. * Fix `gp` when there is text after paste * Match line counting logic of `gP` and `gp`
This commit is contained in:
parent
a3256bb8c6
commit
5d067f4e96
@ -1725,12 +1725,9 @@ export class GPutCommand extends BaseCommand {
|
||||
const result = await super.execCount(position, vimState);
|
||||
|
||||
if (vimState.effectiveRegisterMode === RegisterMode.LineWise) {
|
||||
const line = TextEditor.getLineAt(position).text;
|
||||
const addAnotherLine = line.length > 0 && addedLinesCount > 1;
|
||||
|
||||
result.recordedState.transformations.push({
|
||||
type: 'moveCursor',
|
||||
diff: PositionDiff.NewBOLDiff(1 + (addAnotherLine ? 1 : 0), 0),
|
||||
diff: PositionDiff.NewBOLDiff(addedLinesCount, 0),
|
||||
cursorIndex: this.multicursorIndex,
|
||||
});
|
||||
}
|
||||
@ -1871,12 +1868,9 @@ export class GPutBeforeCommand extends BaseCommand {
|
||||
}
|
||||
|
||||
if (vimState.effectiveRegisterMode === RegisterMode.LineWise) {
|
||||
const line = TextEditor.getLineAt(position).text;
|
||||
const addAnotherLine = line.length > 0 && addedLinesCount > 1;
|
||||
|
||||
result.recordedState.transformations.push({
|
||||
type: 'moveCursor',
|
||||
diff: PositionDiff.NewBOLDiff(1 + (addAnotherLine ? 1 : 0), 0),
|
||||
diff: PositionDiff.NewBOLDiff(addedLinesCount, 0),
|
||||
cursorIndex: this.multicursorIndex,
|
||||
});
|
||||
}
|
||||
|
@ -1148,6 +1148,13 @@ suite('Mode Normal', () => {
|
||||
end: ['one', 'two', 'one', 'two', '|three'],
|
||||
});
|
||||
|
||||
newTest({
|
||||
title: "Can handle 'gp' after 'Nyy' if pasting more than three lines",
|
||||
start: ['on|e', 'two', 'three', 'four'],
|
||||
keysPressed: '4yyGgp',
|
||||
end: ['one', 'two', 'three', 'four', 'one', 'two', 'three', '|four'],
|
||||
});
|
||||
|
||||
newTest({
|
||||
title: "Can handle 'gp' after 'Nyy' if cursor is on the last line",
|
||||
start: ['on|e', 'two', 'three'],
|
||||
@ -1169,6 +1176,13 @@ suite('Mode Normal', () => {
|
||||
end: ['one', 'two', '|one', 'two', 'three'],
|
||||
});
|
||||
|
||||
newTest({
|
||||
title: "Can handle 'gP' after 'Nyy' if pasting more than three lines",
|
||||
start: ['on|e', 'two', 'three', 'four'],
|
||||
keysPressed: '4yygP',
|
||||
end: ['one', 'two', 'three', 'four', '|one', 'two', 'three', 'four'],
|
||||
});
|
||||
|
||||
newTest({
|
||||
title: "Can handle ']p' after yy",
|
||||
start: [' |one', ' two'],
|
||||
|
Loading…
Reference in New Issue
Block a user