浏览代码

Merge pull request #7781 from markellekelly/fbshortcut

Add shortcut for file browser to its tooltip
Steven Silvester 5 年之前
父节点
当前提交
1c1ef71fc4
共有 1 个文件被更改,包括 18 次插入2 次删除
  1. 18 2
      packages/filebrowser-extension/src/index.ts

+ 18 - 2
packages/filebrowser-extension/src/index.ts

@@ -44,7 +44,7 @@ import { IStatusBar } from '@jupyterlab/statusbar';
 
 import { addIcon, folderIcon } from '@jupyterlab/ui-components';
 
-import { IIterator, map, reduce, toArray } from '@lumino/algorithm';
+import { IIterator, map, reduce, toArray, find } from '@lumino/algorithm';
 
 import { CommandRegistry } from '@lumino/commands';
 
@@ -294,7 +294,23 @@ function activateBrowser(
   );
 
   browser.title.iconRenderer = folderIcon;
-  browser.title.caption = 'File Browser';
+  // Show the current file browser shortcut in its title.
+  const updateBrowserTitle = () => {
+    const binding = find(
+      app.commands.keyBindings,
+      b => b.command === CommandIDs.toggleBrowser
+    );
+    if (binding) {
+      const ks = CommandRegistry.formatKeystroke(binding.keys.join(' '));
+      browser.title.caption = `File Browser (${ks})`;
+    } else {
+      browser.title.caption = 'File Browser';
+    }
+  };
+  updateBrowserTitle();
+  app.commands.keyBindingChanged.connect(() => {
+    updateBrowserTitle();
+  });
   labShell.add(browser, 'left', { rank: 100 });
 
   // If the layout is a fresh session without saved data, open file browser.