Skip to content

Commit

Permalink
Fix bang (:!) command with ranges (#7122)
Browse files Browse the repository at this point in the history
Line range tests didn't catch the recent regression
where selection ranges were ignored in the bang command.

Fixes #3136 (again)
  • Loading branch information
tagniam committed Oct 3, 2021
1 parent be298cf commit 0c6a84a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/cmd_line/commands/bang.ts
Expand Up @@ -40,7 +40,7 @@ export class BangCommand extends ExCommand {
const resolvedRange = range.resolveToRange(vimState);

// pipe in stdin from lines in range
const input = vimState.document.getText();
const input = vimState.document.getText(resolvedRange);
const output = await externalCommand.run(this._arguments.command, input);

// place cursor at the start of the replaced text and first non-whitespace character
Expand Down
10 changes: 5 additions & 5 deletions test/cmd_line/bang.test.ts
Expand Up @@ -31,8 +31,8 @@ suite('bang (!) cmd_line', () => {

test('! with line range', async () => {
await modeHandler.handleMultipleKeyEvents(['i', '123\n456\n789', '<Esc>']);
await modeHandler.handleMultipleKeyEvents(':1,3!echo hello world\n'.split(''));
assertEqualLines(['hello world']);
await modeHandler.handleMultipleKeyEvents(':2,3!echo hello world\n'.split(''));
assertEqualLines(['123', 'hello world']);
});
});

Expand Down Expand Up @@ -78,9 +78,9 @@ suite('bang (!) cmd_line', () => {
});

test(':{range}!{cmd} should pass in line range as stdin', async () => {
await modeHandler.handleMultipleKeyEvents(['i', '3\n2\n1', '<Esc>']);
await modeHandler.handleMultipleKeyEvents(':1,3!sort -n\n'.split(''));
assertEqualLines(['1', '2', '3']);
await modeHandler.handleMultipleKeyEvents(['i', '4\n3\n2\n1', '<Esc>']);
await modeHandler.handleMultipleKeyEvents(':2,4!sort -n\n'.split(''));
assertEqualLines(['4', '1', '2', '3']);
});

test('! with commands expecting stdin do not block when no stdin is supplied', async () => {
Expand Down

0 comments on commit 0c6a84a

Please sign in to comment.