|
@@ -516,9 +516,7 @@ function activateNotebookHandler(
|
|
|
settingRegistry: ISettingRegistry | null
|
|
|
): INotebookTracker {
|
|
|
const services = app.serviceManager;
|
|
|
- // An object for tracking the current notebook settings.
|
|
|
- let editorConfig = StaticNotebook.defaultEditorConfig;
|
|
|
- let notebookConfig = StaticNotebook.defaultNotebookConfig;
|
|
|
+
|
|
|
const factory = new NotebookWidgetFactory({
|
|
|
name: FACTORY,
|
|
|
fileTypes: ['notebook'],
|
|
@@ -528,8 +526,8 @@ function activateNotebookHandler(
|
|
|
canStartKernel: true,
|
|
|
rendermime: rendermime,
|
|
|
contentFactory,
|
|
|
- editorConfig,
|
|
|
- notebookConfig,
|
|
|
+ editorConfig: StaticNotebook.defaultEditorConfig,
|
|
|
+ notebookConfig: StaticNotebook.defaultNotebookConfig,
|
|
|
mimeTypeService: editorServices.mimeTypeService
|
|
|
});
|
|
|
const { commands } = app;
|
|
@@ -582,6 +580,15 @@ function activateNotebookHandler(
|
|
|
void tracker.add(widget);
|
|
|
});
|
|
|
|
|
|
+ /**
|
|
|
+ * Update the settings of the current tracker.
|
|
|
+ */
|
|
|
+ function updateTracker(options: NotebookPanel.IConfig): void {
|
|
|
+ tracker.forEach(widget => {
|
|
|
+ widget.setConfig(options);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Update the setting values.
|
|
|
*/
|
|
@@ -616,27 +623,17 @@ function activateNotebookHandler(
|
|
|
? raw[key]
|
|
|
: cached[key];
|
|
|
});
|
|
|
- factory.editorConfig = editorConfig = { code, markdown, raw };
|
|
|
- factory.notebookConfig = notebookConfig = {
|
|
|
+ factory.editorConfig = { code, markdown, raw };
|
|
|
+ factory.notebookConfig = {
|
|
|
scrollPastEnd: settings.get('scrollPastEnd').composite as boolean
|
|
|
};
|
|
|
factory.shutdownOnClose = settings.get('kernelShutdown')
|
|
|
.composite as boolean;
|
|
|
- }
|
|
|
|
|
|
- /**
|
|
|
- * Update the settings of the current tracker.
|
|
|
- */
|
|
|
- function updateTracker(settings: ISettingRegistry.ISettings | null): void {
|
|
|
- tracker.forEach(widget => {
|
|
|
- widget.content.editorConfig = editorConfig;
|
|
|
- widget.content.notebookConfig = notebookConfig;
|
|
|
- // Update kernel shutdown behavior
|
|
|
- const kernelPreference = widget.context.session.kernelPreference;
|
|
|
- widget.context.session.kernelPreference = {
|
|
|
- ...kernelPreference,
|
|
|
- shutdownOnClose: factory.shutdownOnClose
|
|
|
- };
|
|
|
+ updateTracker({
|
|
|
+ editorConfig: factory.editorConfig,
|
|
|
+ notebookConfig: factory.notebookConfig,
|
|
|
+ kernelShutdown: factory.shutdownOnClose
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -648,15 +645,17 @@ function activateNotebookHandler(
|
|
|
.then(() => fetchSettings)
|
|
|
.then(settings => {
|
|
|
updateConfig(settings);
|
|
|
- updateTracker(settings);
|
|
|
settings.changed.connect(() => {
|
|
|
updateConfig(settings);
|
|
|
- updateTracker(settings);
|
|
|
});
|
|
|
})
|
|
|
.catch((reason: Error) => {
|
|
|
console.warn(reason.message);
|
|
|
- updateTracker(null);
|
|
|
+ updateTracker({
|
|
|
+ editorConfig: factory.editorConfig,
|
|
|
+ notebookConfig: factory.notebookConfig,
|
|
|
+ kernelShutdown: factory.shutdownOnClose
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
// Add main menu notebook menu.
|