Skip to content

Commit ac0c50b

Browse files
committed
Added revealInExplorer command (DH-20578)
1 parent 32304ee commit ac0c50b

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,11 @@
309309
"command": "vscode-deephaven.deleteVariable",
310310
"title": "Delete Deephaven Variable",
311311
"icon": "$(trash)"
312+
},
313+
{
314+
"command": "vscode-deephaven.revealInExplorer",
315+
"title": "Reveal in Explorer",
316+
"icon": "$(eye)"
312317
}
313318
],
314319
"icons": {
@@ -832,6 +837,10 @@
832837
{
833838
"command": "vscode-deephaven.deleteVariable",
834839
"when": "false"
840+
},
841+
{
842+
"command": "vscode-deephaven.revealInExplorer",
843+
"when": "false"
835844
}
836845
],
837846
"editor/context": [
@@ -984,6 +993,10 @@
984993
"command": "vscode-deephaven.removePythonRemoteFileSource",
985994
"when": "view == vscode-deephaven.view.remoteImportSourceTree && viewItem == canRemoveRemoteFileSource:python",
986995
"group": "inline"
996+
},
997+
{
998+
"command": "vscode-deephaven.revealInExplorer",
999+
"when": "view == vscode-deephaven.view.remoteImportSourceTree && viewItem != root && viewItem != languageRoot"
9871000
}
9881001
]
9891002
},

src/common/commands.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,4 @@ export const ADD_PYTHON_REMOTE_FILE_SOURCE_CMD = cmd(
8080
export const REMOVE_PYTHON_REMOTE_FILE_SOURCE_CMD = cmd(
8181
'removePythonRemoteFileSource'
8282
);
83+
export const REVEAL_IN_EXPLORER_CMD = cmd('revealInExplorer');

src/controllers/ExtensionController.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
REFRESH_SERVER_TREE_CMD,
2727
REMOVE_GROOVY_REMOTE_FILE_SOURCE_CMD,
2828
REMOVE_PYTHON_REMOTE_FILE_SOURCE_CMD,
29+
REVEAL_IN_EXPLORER_CMD,
2930
RUN_CODE_COMMAND,
3031
RUN_MARKDOWN_CODEBLOCK_CMD,
3132
RUN_SELECTION_COMMAND,
@@ -720,6 +721,9 @@ export class ExtensionController implements IDisposable {
720721
initializeCommands = (): void => {
721722
assertDefined(this._connectionController, 'connectionController');
722723

724+
/** Reveal in Explorer */
725+
this.registerCommand(REVEAL_IN_EXPLORER_CMD, this.onRevealInExplorer);
726+
723727
/** Clear secret storage */
724728
this.registerCommand(CLEAR_SECRET_STORAGE_CMD, this.onClearSecretStorage);
725729

@@ -1147,6 +1151,22 @@ export class ExtensionController implements IDisposable {
11471151
await this._serverManager?.updateStatus();
11481152
};
11491153

1154+
onRevealInExplorer = async (
1155+
uriOrHasUri: vscode.Uri | { uri: vscode.Uri } | undefined
1156+
): Promise<void> => {
1157+
// Sometimes view/item/context commands pass undefined instead of a value.
1158+
// Just ignore. microsoft/vscode#283655
1159+
if (uriOrHasUri == null) {
1160+
logger.debug('onRevealInExplorer', 'uri is undefined');
1161+
return;
1162+
}
1163+
1164+
const uri =
1165+
uriOrHasUri instanceof vscode.Uri ? uriOrHasUri : uriOrHasUri.uri;
1166+
1167+
await vscode.commands.executeCommand('revealInExplorer', uri);
1168+
};
1169+
11501170
/**
11511171
* Run code block in markdown.
11521172
* @param uri The uri of the editor

0 commit comments

Comments
 (0)