Skip to content

Commit

Permalink
display register value in reg-cmd, fix #830 (#915)
Browse files Browse the repository at this point in the history
  • Loading branch information
Platzer authored and johnfn committed Oct 14, 2016
1 parent 4122987 commit 3a3bbae
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions src/cmd_line/commands/register.ts
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@ import { Register} from '../../register/register';
export interface IRegisterCommandArguments extends node.ICommandArgs {
arg?: string;
}

export class RegisterCommand extends node.CommandBase {
protected _arguments : IRegisterCommandArguments;

@@ -23,20 +22,42 @@ export class RegisterCommand extends node.CommandBase {
return this._arguments;
}

async displayRegisterValue(register: string): Promise<void> {
private async getRegisterDisplayValue(register: string) {
let result = (await Register.getByKey(register)).text;
if (result instanceof Array) {
result = result.join("\n").substr(0, 100);
}

return result;
}

async displayRegisterValue(register: string): Promise<void> {
let result = this.getRegisterDisplayValue(register);

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);
const currentRegisterKeys = Register.getKeys();
const registerKeyAndContent = new Array<any>();

for (let registerKey of currentRegisterKeys) {
registerKeyAndContent.push(
{
label: registerKey,
description: await this.getRegisterDisplayValue(registerKey)
}
);
}

vscode.window.showQuickPick(registerKeyAndContent).then(async (val) => {
if (val) {
let result = val.description;
vscode.window.showInformationMessage(`${val.label} ${result}`);
}
});
}
}

0 comments on commit 3a3bbae

Please sign in to comment.