diff --git a/src/actions/commands/actions.ts b/src/actions/commands/actions.ts index 1fe203d197a..b65cdcb7a81 100644 --- a/src/actions/commands/actions.ts +++ b/src/actions/commands/actions.ts @@ -2140,7 +2140,7 @@ export class CommandYankFullLine extends BaseCommand { public async exec(position: Position, vimState: VimState): Promise { const linesDown = (vimState.recordedState.count || 1) - 1; const start = position.getLineBegin(); - const end = new Position(position.line + linesDown, 0).getLineEnd().getLeft(); + const end = position.getDown(linesDown).getLeft(); vimState.currentRegisterMode = RegisterMode.LineWise; @@ -3075,7 +3075,7 @@ class ActionJoin extends BaseCommand { if (position.line + 1 < TextEditor.getLineCount()) { startLineNumber = position.line; startColumn = 0; - endLineNumber = startLineNumber + count; + endLineNumber = position.getDown(count).line; endColumn = TextEditor.getLineLength(endLineNumber); } else { startLineNumber = position.line; diff --git a/test/mode/modeNormal.test.ts b/test/mode/modeNormal.test.ts index 6d1a3d39769..bef8adacaeb 100755 --- a/test/mode/modeNormal.test.ts +++ b/test/mode/modeNormal.test.ts @@ -2016,6 +2016,20 @@ suite('Mode Normal', () => { end: ['blah blah', '|blah blah'], }); + newTest({ + title: 'can do [count]Y', + start: ['|one', 'two', 'three'], + keysPressed: '2Yp', + end: ['one', '|one', 'two', 'two', 'three'], + }); + + newTest({ + title: 'can do [count]Y if count is larger than EOF', + start: ['|one', 'two', 'three'], + keysPressed: '100Yp', + end: ['one', '|one', 'two', 'three', 'two', 'three'], + }); + newTest({ title: 'Can do S', start: [' one', ' tw|o', ' three'], diff --git a/test/mode/normalModeTests/commands.test.ts b/test/mode/normalModeTests/commands.test.ts index dbc60825265..5a73979b27f 100644 --- a/test/mode/normalModeTests/commands.test.ts +++ b/test/mode/normalModeTests/commands.test.ts @@ -276,6 +276,20 @@ suite('Mode Normal', () => { end: ['one|two'], }); + newTest({ + title: "Can handle 'J' with count", + start: ['|one', 'two', 'three', 'four'], + keysPressed: '3J', + end: ['one two| three', 'four'], + }); + + newTest({ + title: "Can handle 'J' with count if count is larger than EOF", + start: ['|one', 'two', 'three', 'four'], + keysPressed: '100J', + end: ['one two three| four'], + }); + newTest({ title: "Can handle 'J' in Visual Line mode", start: ['on|e', 'two'],