Skip to content

Commit

Permalink
use onDidAddNotebookEditor
Browse files Browse the repository at this point in the history
  • Loading branch information
andreamah committed Feb 9, 2023
1 parent aa79ffc commit 99c2baa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export interface INotebookEditorService {
retrieveAllExistingWidgets(): IBorrowValue<NotebookEditorWidget>[];
onDidAddNotebookEditor: Event<INotebookEditor>;
onDidRemoveNotebookEditor: Event<INotebookEditor>;
onDidAddNotebookEditorWidget: Event<NotebookEditorWidget>;
addNotebookEditor(editor: INotebookEditor): void;
removeNotebookEditor(editor: INotebookEditor): void;
getNotebookEditor(editorId: string): INotebookEditor | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ export class NotebookEditorWidgetService implements INotebookEditorService {
readonly onDidAddNotebookEditor = this._onNotebookEditorAdd.event;
readonly onDidRemoveNotebookEditor = this._onNotebookEditorsRemove.event;

private readonly _onDidAddNotebookEditorWidget = new Emitter<NotebookEditorWidget>();
readonly onDidAddNotebookEditorWidget = this._onDidAddNotebookEditorWidget.event;

private readonly _borrowableEditors = new Map<number, ResourceMap<{ widget: NotebookEditorWidget; token: number | undefined }>>();

constructor(
Expand Down Expand Up @@ -161,7 +158,6 @@ export class NotebookEditorWidgetService implements INotebookEditorService {
// NEW widget
const instantiationService = accessor.get(IInstantiationService);
const widget = instantiationService.createInstance(NotebookEditorWidget, creationOptions ?? getDefaultNotebookCreationOptions(), initialDimension);
this._onDidAddNotebookEditorWidget.fire(widget);
const token = this._tokenPool++;
value = { widget, token };

Expand Down
16 changes: 9 additions & 7 deletions src/vs/workbench/contrib/search/browser/searchModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,15 @@ export class SearchResult extends Disposable {
this._rangeHighlightDecorations = this.instantiationService.createInstance(RangeHighlightDecorations);

this._register(this.modelService.onModelAdded(model => this.onModelAdded(model)));
this._register(this.notebookEditorService.onDidAddNotebookEditorWidget(widget => this.onDidAddNotebookEditorWidget(widget)));

const experimentalNotebooksEnabled = this.configurationService.getValue<ISearchConfigurationProperties>('search').experimental.notebookSearch;
if (experimentalNotebooksEnabled) {
this._register(this.notebookEditorService.onDidAddNotebookEditor(widget => {
if (widget instanceof NotebookEditorWidget) {
this.onDidAddNotebookEditorWidget(<NotebookEditorWidget>widget);
}
}));
}

this._register(this.onChange(e => {
if (e.removed) {
Expand Down Expand Up @@ -1405,12 +1413,6 @@ export class SearchResult extends Disposable {
}

private onDidAddNotebookEditorWidget(widget: NotebookEditorWidget): void {
const experimentalNotebooksEnabled = this.configurationService.getValue<ISearchConfigurationProperties>('search').experimental.notebookSearch;

if (!experimentalNotebooksEnabled) {
return;
}

widget.onWillChangeModel(
(model) => {
if (model) {
Expand Down

0 comments on commit 99c2baa

Please sign in to comment.