Skip to content

Commit

Permalink
Apply revealInExplorer vscode command
Browse files Browse the repository at this point in the history
Signed-off-by: Igor Vinokur <[email protected]>
  • Loading branch information
vinokurig committed Sep 24, 2020
1 parent 04c229b commit c6f6e22
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/navigator/src/browser/navigator-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ export namespace NavigatorContextMenu {
export const OPEN_WITH = [...NAVIGATION, 'open_with'];
}

export const FILE_NAVIGATOR_TOGGLE_COMMAND_ID = 'fileNavigator:toggle';

@injectable()
export class FileNavigatorContribution extends AbstractViewContribution<FileNavigatorWidget> implements FrontendApplicationContribution, TabBarToolbarContribution {

Expand Down Expand Up @@ -200,7 +202,7 @@ export class FileNavigatorContribution extends AbstractViewContribution<FileNavi
area: 'left',
rank: 100
},
toggleCommandId: 'fileNavigator:toggle',
toggleCommandId: FILE_NAVIGATOR_TOGGLE_COMMAND_ID,
toggleKeybinding: 'ctrlcmd+shift+e'
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ import { MonacoEditor } from '@theia/monaco/lib/browser/monaco-editor';
import { TerminalFrontendContribution } from '@theia/terminal/lib/browser/terminal-frontend-contribution';
import { QuickOpenWorkspace } from '@theia/workspace/lib/browser/quick-open-workspace';
import { TerminalService } from '@theia/terminal/lib/browser/base/terminal-service';
import { FileNavigatorCommands } from '@theia/navigator/lib/browser/navigator-contribution';
import {
FileNavigatorCommands,
FILE_NAVIGATOR_TOGGLE_COMMAND_ID
} from '@theia/navigator/lib/browser/navigator-contribution';
import { FILE_NAVIGATOR_ID, FileNavigatorWidget } from '@theia/navigator/lib/browser';
import { SelectableTreeNode } from '@theia/core/lib/browser/tree/tree-selection';

export namespace VscodeCommands {
export const OPEN: Command = {
Expand Down Expand Up @@ -574,5 +579,26 @@ export class PluginVscodeCommandsContribution implements CommandContribution {
}, {
execute: () => commands.executeCommand(FileNavigatorCommands.COPY_RELATIVE_FILE_PATH.id)
});
commands.registerCommand({
id: 'revealInExplorer'
}, {
execute: async (resource: URI | object) => {
if (!URI.isUri(resource)) {
return;
}
let navigator = await this.shell.revealWidget(FILE_NAVIGATOR_ID);
if (!navigator) {
await this.commandService.executeCommand(FILE_NAVIGATOR_TOGGLE_COMMAND_ID);
navigator = await this.shell.revealWidget(FILE_NAVIGATOR_ID);
}
if (navigator instanceof FileNavigatorWidget) {
const model = navigator.model;
const node = await model.revealFile(new TheiaURI(resource));
if (SelectableTreeNode.is(node)) {
model.selectNode(node);
}
}
}
});
}
}

0 comments on commit c6f6e22

Please sign in to comment.