Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reset log display and count when non-notebook tab gets activated #7334

Merged
merged 1 commit into from Oct 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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