mirror of
https://github.com/VSCodeVim/Vim.git
synced 2024-10-04 07:38:27 +03:00
Fix :p[ut] command neovim capability and subparser (#5063)
Enables neovim capability and fixes arg parsing for the `:p[ut]` command. Apparently the put command allows no whitespace between the command name and the register name, so commands like `:put"` are perfectly valid. I've added some subparser tests to document this. Fixes #5052 Fixes #5090
This commit is contained in:
parent
b74ccf6244
commit
e0da682ac0
@ -27,6 +27,10 @@ export class PutExCommand extends node.CommandBase {
|
||||
return this._arguments;
|
||||
}
|
||||
|
||||
public neovimCapable(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
async doPut(vimState: VimState, position: Position) {
|
||||
const registerName = this.arguments.register || (configuration.useSystemClipboard ? '*' : '"');
|
||||
vimState.recordedState.registerName = registerName;
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { PutExCommand, IPutCommandArguments } from '../commands/put';
|
||||
import { ErrorCode, VimError } from '../../error';
|
||||
import { Scanner } from '../scanner';
|
||||
|
||||
export function parsePutExCommandArgs(args: string): PutExCommand {
|
||||
@ -14,8 +13,8 @@ export function parsePutExCommandArgs(args: string): PutExCommand {
|
||||
if (c === '!') {
|
||||
scannedArgs.bang = true;
|
||||
scanner.ignore();
|
||||
} else if (c !== ' ') {
|
||||
throw VimError.fromCode(ErrorCode.TrailingCharacters);
|
||||
} else {
|
||||
scanner.backup();
|
||||
}
|
||||
scanner.skipWhiteSpace();
|
||||
|
||||
|
34
test/cmd_line/subparser.put.test.ts
Normal file
34
test/cmd_line/subparser.put.test.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import * as assert from 'assert';
|
||||
import { commandParsers } from '../../src/cmd_line/subparser';
|
||||
|
||||
suite(':put args parser', () => {
|
||||
test('can parse empty args', () => {
|
||||
const args = commandParsers.put.parser('');
|
||||
assert.strictEqual(args.arguments.bang, undefined);
|
||||
assert.strictEqual(args.arguments.register, undefined);
|
||||
});
|
||||
|
||||
test('can parse !', () => {
|
||||
const args = commandParsers.put.parser('!');
|
||||
assert.strictEqual(args.arguments.bang, true);
|
||||
assert.strictEqual(args.arguments.range, undefined);
|
||||
});
|
||||
|
||||
test('can parse register', () => {
|
||||
const args = commandParsers.put.parser(' *');
|
||||
assert.strictEqual(args.arguments.bang, undefined);
|
||||
assert.strictEqual(args.arguments.register, '*');
|
||||
});
|
||||
|
||||
test('can parse register with no whitespace', () => {
|
||||
const args = commandParsers.put.parser('*');
|
||||
assert.strictEqual(args.arguments.bang, undefined);
|
||||
assert.strictEqual(args.arguments.register, '*');
|
||||
});
|
||||
|
||||
test('can parse register with no whitespace and !', () => {
|
||||
const args = commandParsers.put.parser('!*');
|
||||
assert.strictEqual(args.arguments.bang, true);
|
||||
assert.strictEqual(args.arguments.register, '*');
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user