Skip to content

Commit

Permalink
fixed notebook and text editors side by side not being set as active …
Browse files Browse the repository at this point in the history
…correctly

Signed-off-by: Jonah Iden <[email protected]>
  • Loading branch information
jonah-iden committed Sep 18, 2024
1 parent e6059d5 commit 4400f11
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 15 additions & 2 deletions packages/plugin-ext/src/main/browser/editors-and-documents-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { DisposableCollection, Emitter, URI } from '@theia/core';
import { EditorManager, EditorWidget } from '@theia/editor/lib/browser';
import { SaveableService } from '@theia/core/lib/browser/saveable-service';
import { TabsMainImpl } from './tabs/tabs-main';
import { NotebookCellEditorService } from '@theia/notebook/lib/browser';
import { NotebookCellEditorService, NotebookEditorWidgetService } from '@theia/notebook/lib/browser';
import { SimpleMonacoEditor } from '@theia/monaco/lib/browser/simple-monaco-editor';

export class EditorsAndDocumentsMain implements Disposable {
Expand Down Expand Up @@ -69,7 +69,11 @@ export class EditorsAndDocumentsMain implements Disposable {
this.modelService = container.get(EditorModelService);
this.saveResourceService = container.get(SaveableService);

this.stateComputer = new EditorAndDocumentStateComputer(d => this.onDelta(d), this.editorManager, container.get(NotebookCellEditorService), this.modelService, tabsMain);
this.stateComputer = new EditorAndDocumentStateComputer(d => this.onDelta(d),
this.editorManager,
container.get(NotebookCellEditorService),
container.get(NotebookEditorWidgetService),
this.modelService, tabsMain);
this.toDispose.push(this.stateComputer);
this.toDispose.push(this.onTextEditorAddEmitter);
this.toDispose.push(this.onTextEditorRemoveEmitter);
Expand Down Expand Up @@ -221,6 +225,7 @@ class EditorAndDocumentStateComputer implements Disposable {
private callback: (delta: EditorAndDocumentStateDelta) => void,
private readonly editorService: EditorManager,
private readonly cellEditorService: NotebookCellEditorService,
private readonly notebookWidgetService: NotebookEditorWidgetService,
private readonly modelService: EditorModelService,
private readonly tabsMain: TabsMainImpl
) { }
Expand All @@ -245,6 +250,14 @@ class EditorAndDocumentStateComputer implements Disposable {

this.toDispose.push(this.cellEditorService.onDidChangeCellEditors(() => this.update()));

this.toDispose.push(this.notebookWidgetService.onDidChangeFocusedEditor(() => {
this.currentState = this.currentState && new EditorAndDocumentState(
this.currentState.documents,
this.currentState.editors,
undefined
);
}));

for (const widget of this.editorService.all) {
this.onTextEditorAdd(widget);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-ext/src/plugin/notebook/notebooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ export class NotebooksExtImpl implements NotebooksExt {
console.error(`FAILED to find active notebook editor ${delta.newActiveEditor}`);
}
this.activeNotebookEditor = this.editors.get(delta.newActiveEditor);
if (!(this.textDocumentsAndEditors.activeEditor()?.document.uri.path === this.activeNotebookEditor?.notebookData.uri.path)) {
if (this.textDocumentsAndEditors.activeEditor()?.document.uri.path !== this.activeNotebookEditor?.notebookData.uri.path) {
this.textDocumentsAndEditors.acceptEditorsAndDocumentsDelta({
newActiveEditor: null
});
Expand Down

0 comments on commit 4400f11

Please sign in to comment.