Skip to content

Commit

Permalink
Backport PR jupyterlab#7334: reset log display and count when non-not…
Browse files Browse the repository at this point in the history
…ebook tab gets activated
  • Loading branch information
jasongrout authored and MeeseeksDev[bot] committed Oct 12, 2019
1 parent 79624fc commit fc3f4c9
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/logconsole-extension/src/index.tsx
Expand Up @@ -2,6 +2,7 @@
// Distributed under the terms of the Modified BSD License.

import {
ILabShell,
JupyterFrontEnd,
JupyterFrontEndPlugin,
ILayoutRestorer
Expand Down Expand Up @@ -55,6 +56,7 @@ const logConsolePlugin: JupyterFrontEndPlugin<ILoggerRegistry> = {
id: LOG_CONSOLE_PLUGIN_ID,
provides: ILoggerRegistry,
requires: [
ILabShell,
IMainMenu,
ICommandPalette,
INotebookTracker,
Expand Down Expand Up @@ -373,6 +375,7 @@ export namespace LogConsoleStatus {
*/
function activateLogConsole(
app: JupyterFrontEnd,
labShell: ILabShell,
mainMenu: IMainMenu,
palette: ICommandPalette,
nbtracker: INotebookTracker,
Expand Down Expand Up @@ -556,6 +559,21 @@ function activateLogConsole(
}
);

labShell.currentChanged.connect((_, change) => {
const newValue = change.newValue;

// if a new tab is activated which is not a notebook,
// then reset log display and count
if (newValue && newValue !== logConsoleWidget && !nbtracker.has(newValue)) {
if (logConsoleWidget) {
logConsoleWidget.content.activeSource = null;
void tracker.save(logConsoleWidget);
}

status.model.activeSource = null;
}
});

if (settingRegistry) {
const updateSettings = (settings: ISettingRegistry.ISettings): void => {
const maxLogEntries = settings.get('maxLogEntries').composite as number;
Expand Down

0 comments on commit fc3f4c9

Please sign in to comment.