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

Closed notebook search: current result not highlighted on notebook open #188719

Merged
merged 1 commit into from
Jul 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/vs/workbench/contrib/search/browser/searchModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,12 @@ export class FileMatch extends Disposable implements IFileMatch {

setSelectedMatch(match: Match | null): void {
if (match) {

if (!this.isMatchSelected(match) && match instanceof MatchInNotebook) {
this._selectedMatch = match;
return;
}

if (!this._textMatches.has(match.id())) {
return;
}
Expand Down Expand Up @@ -765,6 +771,9 @@ export class FileMatch extends Disposable implements IFileMatch {
this._findMatchDecorationModel?.stopWebviewFind();
this._findMatchDecorationModel?.dispose();
this._findMatchDecorationModel = new FindMatchDecorationModel(this._notebookEditorWidget, this.searchInstanceID);
if (this._selectedMatch instanceof MatchInNotebook) {
this.highlightCurrentFindMatchDecoration(this._selectedMatch);
}
}

private _removeNotebookHighlights(): void {
Expand All @@ -780,6 +789,7 @@ export class FileMatch extends Disposable implements IFileMatch {
return;
}

const oldCellMatches = new Map<string, CellMatch>(this._cellMatches);
if (this._notebookEditorWidget.getId() !== this._lastEditorWidgetIdForUpdate) {
this._cellMatches.clear();
this._lastEditorWidgetIdForUpdate = this._notebookEditorWidget.getId();
Expand All @@ -790,10 +800,9 @@ export class FileMatch extends Disposable implements IFileMatch {
let existingCell = this._cellMatches.get(match.cell.id);
if (this._notebookEditorWidget && !existingCell) {
const index = this._notebookEditorWidget.getCellIndex(match.cell);
const existingRawCell = this._cellMatches.get(`${rawCellPrefix}${index}`);
const existingRawCell = oldCellMatches.get(`${rawCellPrefix}${index}`);
if (existingRawCell) {
existingRawCell.setCellModel(match.cell);
this._cellMatches.delete(`${rawCellPrefix}${index}`);
existingCell = existingRawCell;
}
}
Expand All @@ -805,6 +814,9 @@ export class FileMatch extends Disposable implements IFileMatch {
});

this._findMatchDecorationModel?.setAllFindMatchesDecorations(matches);
if (this._selectedMatch instanceof MatchInNotebook) {
this.highlightCurrentFindMatchDecoration(this._selectedMatch);
}
this._onChange.fire({ forceUpdateModel: modelChange });
}

Expand Down