Skip to content

Commit 23a64c9

Browse files
committed
example implementation of target arg in execute of a command
uses latest version of PR phosphorjs/phosphor#355
1 parent 489d162 commit 23a64c9

File tree

1 file changed

+10
-2
lines changed
  • packages/docmanager-extension/src

1 file changed

+10
-2
lines changed

packages/docmanager-extension/src/index.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,17 @@ function addCommands(
596596
commands.addCommand(CommandIDs.showInFileBrowser, {
597597
label: () => `Show in File Browser`,
598598
isEnabled,
599-
execute: args => {
599+
execute: (args, target) => {
600+
// give 1st precedence to explicitly passed path
600601
let path = args['path'];
602+
if (!path && target) {
603+
// give 2nd precedence to path on the target node, if present
604+
path = target.dataset['path'];
605+
}
606+
if (!path) {
607+
// fall back to path of focused widget
608+
path = docManager.contextForWidget(shell.currentWidget).path;
609+
}
601610
if (!path) {
602611
return;
603612
}
@@ -634,7 +643,6 @@ function addCommands(
634643
});
635644
app.contextMenu.addItem({
636645
command: CommandIDs.showInFileBrowser,
637-
passDataset: true,
638646
selector: '[data-type="document-title"]',
639647
rank: 3
640648
});

0 commit comments

Comments
 (0)