Browse Source

Adds Uris command context (for multi-select)

main
Eric Amodio 5 years ago
parent
commit
7db7f44798
1 changed files with 10 additions and 0 deletions
  1. +10
    -0
      src/commands/common.ts

+ 10
- 0
src/commands/common.ts View File

@ -220,6 +220,11 @@ export interface CommandUriContext extends CommandBaseContext {
type: 'uri'; type: 'uri';
} }
export interface CommandUrisContext extends CommandBaseContext {
type: 'uris';
uris: Uri[];
}
// export interface CommandViewContext extends CommandBaseContext { // export interface CommandViewContext extends CommandBaseContext {
// type: 'view'; // type: 'view';
// } // }
@ -326,6 +331,7 @@ export type CommandContext =
| CommandScmStatesContext | CommandScmStatesContext
| CommandUnknownContext | CommandUnknownContext
| CommandUriContext | CommandUriContext
| CommandUrisContext
// | CommandViewContext // | CommandViewContext
| CommandViewItemContext; | CommandViewItemContext;
@ -415,6 +421,10 @@ export abstract class Command implements Disposable {
if (options.uri && (firstArg == null || firstArg instanceof Uri)) { if (options.uri && (firstArg == null || firstArg instanceof Uri)) {
const [uri, ...rest] = args as [Uri, any]; const [uri, ...rest] = args as [Uri, any];
if (uri !== undefined) { if (uri !== undefined) {
const uris = rest[0];
if (uris != null && Array.isArray(uris) && uris.length !== 0 && uris[0] instanceof Uri) {
return [{ command: command, type: 'uris', editor: editor, uri: uri, uris: uris }, rest.slice(1)];
}
return [{ command: command, type: 'uri', editor: editor, uri: uri }, rest]; return [{ command: command, type: 'uri', editor: editor, uri: uri }, rest];
} }

Loading…
Cancel
Save