Skip to content

Commit e92d180

Browse files
committed
Added revealInExplorer command (DH-20578)
1 parent f4ae833 commit e92d180

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
@@ -25,6 +25,7 @@ import {
2525
REFRESH_SERVER_TREE_CMD,
2626
REMOVE_GROOVY_REMOTE_FILE_SOURCE_CMD,
2727
REMOVE_PYTHON_REMOTE_FILE_SOURCE_CMD,
28+
REVEAL_IN_EXPLORER_CMD,
2829
RUN_CODE_COMMAND,
2930
RUN_MARKDOWN_CODEBLOCK_CMD,
3031
RUN_SELECTION_COMMAND,
@@ -729,6 +730,9 @@ export class ExtensionController implements IDisposable {
729730
initializeCommands = (): void => {
730731
assertDefined(this._connectionController, 'connectionController');
731732

733+
/** Reveal in Explorer */
734+
this.registerCommand(REVEAL_IN_EXPLORER_CMD, this.onRevealInExplorer);
735+
732736
/** Clear secret storage */
733737
this.registerCommand(CLEAR_SECRET_STORAGE_CMD, this.onClearSecretStorage);
734738

@@ -1156,6 +1160,22 @@ export class ExtensionController implements IDisposable {
11561160
await this._serverManager?.updateStatus();
11571161
};
11581162

1163+
onRevealInExplorer = async (
1164+
uriOrHasUri: vscode.Uri | { uri: vscode.Uri } | undefined
1165+
): Promise<void> => {
1166+
// Sometimes view/item/context commands pass undefined instead of a value.
1167+
// Just ignore. microsoft/vscode#283655
1168+
if (uriOrHasUri == null) {
1169+
logger.debug('onRevealInExplorer', 'uri is undefined');
1170+
return;
1171+
}
1172+
1173+
const uri =
1174+
uriOrHasUri instanceof vscode.Uri ? uriOrHasUri : uriOrHasUri.uri;
1175+
1176+
await vscode.commands.executeCommand('revealInExplorer', uri);
1177+
};
1178+
11591179
/**
11601180
* Run code block in markdown.
11611181
* @param uri The uri of the editor

0 commit comments

Comments
 (0)