Skip to content

Commit

Permalink
Merge pull request #7781 from markellekelly/fbshortcut
Browse files Browse the repository at this point in the history
Add shortcut for file browser to its tooltip
  • Loading branch information
Steven Silvester committed Jan 14, 2020
2 parents 6111f2b + 991d3cd commit 1c1ef71
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions packages/filebrowser-extension/src/index.ts
Expand Up @@ -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';

Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 1c1ef71

Please sign in to comment.