Skip to content

Commit 51cf6a0

Browse files
authored
Notebook search highlights are not hidden when closing the search sidebar (microsoft#187017)
Fixes microsoft#185289
1 parent 481c26a commit 51cf6a0

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

src/vs/workbench/contrib/search/browser/searchModel.ts

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -723,10 +723,7 @@ export class FileMatch extends Disposable implements IFileMatch {
723723
}
724724
this._notebookUpdateScheduler.schedule();
725725
}) ?? null;
726-
727-
this._findMatchDecorationModel?.stopWebviewFind();
728-
this._findMatchDecorationModel?.dispose();
729-
this._findMatchDecorationModel = new FindMatchDecorationModel(this._notebookEditorWidget);
726+
this._addNotebookHighlights();
730727
}
731728

732729
unbindNotebookEditorWidget(widget?: NotebookEditorWidget) {
@@ -738,13 +735,34 @@ export class FileMatch extends Disposable implements IFileMatch {
738735
this._notebookUpdateScheduler.cancel();
739736
this._editorWidgetListener?.dispose();
740737
}
738+
this._removeNotebookHighlights();
739+
this._notebookEditorWidget = null;
740+
}
741+
742+
updateNotebookHighlights(): void {
743+
if (this.parent().showHighlights) {
744+
this._addNotebookHighlights();
745+
this.setNotebookFindMatchDecorationsUsingCellMatches(Array.from(this._cellMatches.values()));
746+
} else {
747+
this._removeNotebookHighlights();
748+
}
749+
}
741750

751+
private _addNotebookHighlights(): void {
752+
if (!this._notebookEditorWidget) {
753+
return;
754+
}
755+
this._findMatchDecorationModel?.stopWebviewFind();
756+
this._findMatchDecorationModel?.dispose();
757+
this._findMatchDecorationModel = new FindMatchDecorationModel(this._notebookEditorWidget);
758+
}
759+
760+
private _removeNotebookHighlights(): void {
742761
if (this._findMatchDecorationModel) {
743762
this._findMatchDecorationModel?.stopWebviewFind();
744763
this._findMatchDecorationModel?.dispose();
745764
this._findMatchDecorationModel = undefined;
746765
}
747-
this._notebookEditorWidget = null;
748766
}
749767
private updateNotebookMatches(matches: CellFindMatchWithIndex[], modelChange: boolean): void {
750768

@@ -1808,6 +1826,7 @@ export class SearchResult extends Disposable {
18081826
let selectedMatch: Match | null = null;
18091827
this.matches().forEach((fileMatch: FileMatch) => {
18101828
fileMatch.updateHighlights();
1829+
fileMatch.updateNotebookHighlights();
18111830
if (!selectedMatch) {
18121831
selectedMatch = fileMatch.getSelectedMatch();
18131832
}

0 commit comments

Comments
 (0)