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

Fix notebook widget icon on reload #13612

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

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