mirror of
https://github.com/VSCodeVim/Vim.git
synced 2024-09-11 12:25:59 +03:00
Register info (#756)
* show the content of registers * update roadmap for register * make tslint happy
This commit is contained in:
parent
e5592e5c9e
commit
436166d55c
@ -304,8 +304,8 @@ Status | Command | Description | Note
|
||||
---|--------|-------------|-----------------
|
||||
:running: | "{char} | use register {char} for the next delete, yank, or put | read only registers are not supported yet
|
||||
:white_check_mark: | "* | use register `*` to access system clipboard
|
||||
| :reg | show the contents of all registers
|
||||
| :reg {arg} | show the contents of registers mentioned in {arg}
|
||||
:white_check_mark: | :reg | show the contents of all registers
|
||||
:white_check_mark: | :reg {arg} | show the contents of registers mentioned in {arg}
|
||||
:white_check_mark: | :1234: y{motion} | yank the text moved over with {motion} into a register
|
||||
:white_check_mark: | {visual}y | yank the highlighted text into a register
|
||||
:white_check_mark: | :1234: yy | yank N lines into a register
|
||||
|
43
src/cmd_line/commands/register.ts
Normal file
43
src/cmd_line/commands/register.ts
Normal file
@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
|
||||
import * as vscode from "vscode";
|
||||
import * as node from "../node";
|
||||
import {ModeHandler} from "../../mode/modeHandler";
|
||||
import { Register} from '../../register/register';
|
||||
|
||||
export interface IRegisterCommandArguments extends node.ICommandArgs {
|
||||
arg?: string;
|
||||
}
|
||||
|
||||
export class RegisterCommand extends node.CommandBase {
|
||||
protected _arguments : IRegisterCommandArguments;
|
||||
|
||||
constructor(args : IRegisterCommandArguments) {
|
||||
super();
|
||||
this._name = 'register';
|
||||
this._shortName = 'reg';
|
||||
this._arguments = args;
|
||||
}
|
||||
|
||||
get arguments() : IRegisterCommandArguments{
|
||||
return this._arguments;
|
||||
}
|
||||
|
||||
async displayRegisterValue(register: string): Promise<void> {
|
||||
let result = (await Register.getByKey(register)).text;
|
||||
if (result instanceof Array) {
|
||||
result = result.join("\n").substr(0, 100);
|
||||
}
|
||||
vscode.window.showInformationMessage(`${register} ${result}`);
|
||||
}
|
||||
|
||||
async execute(modeHandler: ModeHandler): Promise<void> {
|
||||
if (this.arguments.arg !== undefined && this.arguments.arg.length > 0) {
|
||||
await this.displayRegisterValue(this.arguments.arg);
|
||||
} else {
|
||||
vscode.window.showQuickPick(Register.getKeys()).then(async (val) => {
|
||||
await this.displayRegisterValue(val);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@ import * as tabCmd from './subparsers/tab';
|
||||
import * as fileCmd from './subparsers/file';
|
||||
import {parseOptionsCommandArgs} from './subparsers/setoptions';
|
||||
import {parseSubstituteCommandArgs} from './subparsers/substitute';
|
||||
import {parseRegisterCommandArgs} from './subparsers/register';
|
||||
|
||||
// maps command names to parsers for said commands.
|
||||
export const commandParsers = {
|
||||
@ -58,5 +59,7 @@ export const commandParsers = {
|
||||
vnew: fileCmd.parseEditNewFileInNewWindowCommandArgs,
|
||||
|
||||
set: parseOptionsCommandArgs,
|
||||
se: parseOptionsCommandArgs
|
||||
se: parseOptionsCommandArgs,
|
||||
|
||||
reg: parseRegisterCommandArgs
|
||||
};
|
||||
|
17
src/cmd_line/subparsers/register.ts
Normal file
17
src/cmd_line/subparsers/register.ts
Normal file
@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
|
||||
import * as node from "../commands/register";
|
||||
import {Scanner} from '../scanner';
|
||||
|
||||
export function parseRegisterCommandArgs(args: string): node.RegisterCommand {
|
||||
if (!args) {
|
||||
return new node.RegisterCommand({});
|
||||
}
|
||||
|
||||
let scanner = new Scanner(args);
|
||||
let name = scanner.nextWord();
|
||||
|
||||
return new node.RegisterCommand({
|
||||
arg: name
|
||||
});
|
||||
}
|
@ -64,7 +64,10 @@ export class Register {
|
||||
*/
|
||||
public static async get(vimState: VimState): Promise<IRegisterContent> {
|
||||
const register = vimState.recordedState.registerName;
|
||||
return Register.getByKey(register);
|
||||
}
|
||||
|
||||
public static async getByKey(register: string): Promise<IRegisterContent> {
|
||||
if (!Register.isValidRegister(register)) {
|
||||
throw new Error(`Invalid register ${register}`);
|
||||
}
|
||||
@ -89,4 +92,8 @@ export class Register {
|
||||
|
||||
return Register.registers[register];
|
||||
}
|
||||
|
||||
public static getKeys(): string[] {
|
||||
return Object.keys(Register.registers);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user