Skip to content

Commit

Permalink
when printing commands for keybindings, skip those that declare argum…
Browse files Browse the repository at this point in the history
…ents and those that start with `vscode.', fixes #4915.
  • Loading branch information
jrieken committed Apr 6, 2016
1 parent 1373840 commit 36439ca
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions src/vs/platform/keybinding/browser/keybindingServiceImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ import {IHTMLContentElement} from 'vs/base/common/htmlContent';
import {KeyCode, Keybinding} from 'vs/base/common/keyCodes';
import {IDisposable, dispose} from 'vs/base/common/lifecycle';
import Severity from 'vs/base/common/severity';
import {isFalsyOrEmpty} from 'vs/base/common/arrays';
import {TPromise} from 'vs/base/common/winjs.base';
import * as dom from 'vs/base/browser/dom';
import {IKeyboardEvent, StandardKeyboardEvent} from 'vs/base/browser/keyboardEvent';
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
import {KeybindingResolver} from 'vs/platform/keybinding/common/keybindingResolver';
import {ICommandHandler, IKeybindingContextKey, IKeybindingItem, IKeybindingScopeLocation, IKeybindingService, SET_CONTEXT_COMMAND_ID} from 'vs/platform/keybinding/common/keybindingService';
import {ICommandHandler, ICommandHandlerDescription, IKeybindingContextKey, IKeybindingItem, IKeybindingScopeLocation, IKeybindingService, SET_CONTEXT_COMMAND_ID} from 'vs/platform/keybinding/common/keybindingService';
import {KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry';
import {IMessageService} from 'vs/platform/message/common/message';
import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
Expand Down Expand Up @@ -258,10 +259,25 @@ export abstract class KeybindingService extends AbstractKeybindingService implem
}

private _getAllCommandsAsComment(): string {
let boundCommands = this._getResolver().getDefaultBoundCommands();
let unboundCommands = Object.keys(KeybindingsRegistry.getCommands()).filter(commandId => commandId[0] !== '_' && !boundCommands[commandId]);
unboundCommands.sort();
let pretty = unboundCommands.join('\n// - ');
const commands = KeybindingsRegistry.getCommands();
const unboundCommands: string[] = [];
const boundCommands = this._getResolver().getDefaultBoundCommands();

for (let id in commands) {
if (id[0] === '_' || id.indexOf('vscode.') === 0) { // private command
continue;
}
if (typeof commands[id].description === 'object'
&& !isFalsyOrEmpty((<ICommandHandlerDescription>commands[id].description).args)) { // command with args
continue;
}
if (boundCommands[id]) {
continue;
}
unboundCommands.push(id);
}

let pretty = unboundCommands.sort().join('\n// - ');

return '// ' + nls.localize('unboundCommands', "Here are other available commands: ") + '\n// - ' + pretty;
}
Expand Down

0 comments on commit 36439ca

Please sign in to comment.