diff --git a/src/sql/workbench/contrib/notebook/browser/notebookEditor.ts b/src/sql/workbench/contrib/notebook/browser/notebookEditor.ts index f4f627eecc..eec8b5e7b8 100644 --- a/src/sql/workbench/contrib/notebook/browser/notebookEditor.ts +++ b/src/sql/workbench/contrib/notebook/browser/notebookEditor.ts @@ -334,8 +334,10 @@ export class NotebookEditor extends BaseEditor implements IFindNotebookControlle this._currentMatch = range; } public toggleSearch(): void { + // reveal only when the model is loaded + let isRevealed: boolean = !this._findState.isRevealed && this._notebookModel ? !this._findState.isRevealed : false; this._findState.change({ - isRevealed: !this._findState.isRevealed + isRevealed: isRevealed }, false); if (this._findState.isRevealed) { this._finder.focusFindInput(); diff --git a/src/sql/workbench/contrib/notebook/find/notebookFindDecorations.ts b/src/sql/workbench/contrib/notebook/find/notebookFindDecorations.ts index dea316fc87..a5a1b01efa 100644 --- a/src/sql/workbench/contrib/notebook/find/notebookFindDecorations.ts +++ b/src/sql/workbench/contrib/notebook/find/notebookFindDecorations.ts @@ -144,6 +144,8 @@ export class NotebookFindDecorations implements IDisposable { private _revealRangeInCenterIfOutsideViewport(match: NotebookRange): void { let matchEditor = this._editor.getCellEditor(match.cell.cellGuid); + // expand the cell if it's collapsed and scroll into view + match.cell.isCollapsed = false; if (matchEditor) { matchEditor.getContainer().scrollIntoView({ behavior: 'smooth', block: 'nearest' }); matchEditor.getControl().revealRangeInCenterIfOutsideViewport(match, ScrollType.Smooth); diff --git a/src/sql/workbench/contrib/notebook/find/notebookFindModel.ts b/src/sql/workbench/contrib/notebook/find/notebookFindModel.ts index 6ec53c7e9d..385ee7cfa2 100644 --- a/src/sql/workbench/contrib/notebook/find/notebookFindModel.ts +++ b/src/sql/workbench/contrib/notebook/find/notebookFindModel.ts @@ -649,9 +649,10 @@ abstract class SettingsCommand extends Command { class SearchNotebookCommand extends SettingsCommand { - public runCommand(accessor: ServicesAccessor, args: any): void { + public async runCommand(accessor: ServicesAccessor, args: any): Promise { const notebookEditor = this.getNotebookEditor(accessor); if (notebookEditor) { + await notebookEditor.setNotebookModel(); notebookEditor.toggleSearch(); } }