Skip to content

Commit

Permalink
Fix notebook widget icon on reload (#13612)
Browse files Browse the repository at this point in the history
  • Loading branch information
msujew authored Apr 22, 2024
1 parent 346822b commit 7ed5fcb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
23 changes: 18 additions & 5 deletions packages/notebook/src/browser/notebook-editor-widget-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
// *****************************************************************************

import { URI } from '@theia/core';
import { nls, URI } from '@theia/core';
import { WidgetFactory, NavigatableWidgetOptions, LabelProvider } from '@theia/core/lib/browser';
import { inject, injectable } from '@theia/core/shared/inversify';
import { NotebookEditorWidget, NotebookEditorWidgetContainerFactory, NotebookEditorProps } from './notebook-editor-widget';
Expand Down Expand Up @@ -51,10 +51,13 @@ export class NotebookEditorWidgetFactory implements WidgetFactory {

const editor = await this.createEditor(uri, options.notebookType);

const icon = this.labelProvider.getIcon(uri);
editor.title.label = this.labelProvider.getName(uri);
editor.title.iconClass = icon + ' file-icon';

this.setLabels(editor, uri);
const labelListener = this.labelProvider.onDidChange(event => {
if (event.affects(uri)) {
this.setLabels(editor, uri);
}
});
editor.onDidDispose(() => labelListener.dispose());
return editor;
}

Expand All @@ -67,4 +70,14 @@ export class NotebookEditorWidgetFactory implements WidgetFactory {
});
}

private setLabels(editor: NotebookEditorWidget, uri: URI): void {
editor.title.caption = uri.path.fsPath();
if (editor.model?.readOnly) {
editor.title.caption += ` • ${nls.localizeByDefault('Read-only')}`;
}
const icon = this.labelProvider.getIcon(uri);
editor.title.label = this.labelProvider.getName(uri);
editor.title.iconClass = icon + ' file-icon';
}

}
2 changes: 1 addition & 1 deletion packages/notebook/src/browser/notebook-editor-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export class NotebookEditorWidget extends ReactWidget implements Navigatable, Sa
readonly onPostRendererMessage = this.onPostRendererMessageEmitter.event;

protected readonly onDidReceiveKernelMessageEmitter = new Emitter<unknown>();
readonly onDidRecieveKernelMessage = this.onDidReceiveKernelMessageEmitter.event;
readonly onDidReceiveKernelMessage = this.onDidReceiveKernelMessageEmitter.event;

protected readonly renderers = new Map<CellKind, CellRenderer>();
protected _model?: NotebookModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export class NotebookKernelsMainImpl implements NotebookKernelsMain {
this.notebookEditorWidgetService = container.get(NotebookEditorWidgetService);

this.notebookEditorWidgetService.onDidAddNotebookEditor(editor => {
editor.onDidRecieveKernelMessage(async message => {
editor.onDidReceiveKernelMessage(async message => {
const kernel = this.notebookKernelService.getSelectedOrSuggestedKernel(editor.model!);
if (kernel) {
this.proxy.$acceptKernelMessageFromRenderer(kernel.handle, editor.id, message);
Expand Down

0 comments on commit 7ed5fcb

Please sign in to comment.