From e8b22318bfab2e52d5dbceee767e8b4bfe9b5300 Mon Sep 17 00:00:00 2001 From: Peng Lyu Date: Wed, 21 Jun 2023 18:28:05 -0700 Subject: [PATCH] Turn md cell to preview when hiding replace input (#185823) --- .../browser/contrib/find/findModel.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/vs/workbench/contrib/notebook/browser/contrib/find/findModel.ts b/src/vs/workbench/contrib/notebook/browser/contrib/find/findModel.ts index 9da02fa3f15..e08a00a42cb 100644 --- a/src/vs/workbench/contrib/notebook/browser/contrib/find/findModel.ts +++ b/src/vs/workbench/contrib/notebook/browser/contrib/find/findModel.ts @@ -162,6 +162,25 @@ export class FindModel extends Disposable { }; + if (e.isReplaceRevealed && !this._state.isReplaceRevealed) { + // replace is hidden, we need to switch all markdown cells to preview mode + const viewModel = this._notebookEditor._getViewModel() as NotebookViewModel | undefined; + if (!viewModel) { + return; + } + + for (let i = 0; i < viewModel.length; i++) { + const cell = viewModel.cellAt(i); + if (cell && cell.cellKind === CellKind.Markup) { + if (cell.getEditState() === CellEditState.Editing && cell.editStateSource === 'find') { + cell.updateEditState(CellEditState.Preview, 'find'); + } + } + } + + return; + } + if (e.isReplaceRevealed) { updateEditingState(); } else if ((e.filters || e.isRevealed || e.searchString || e.replaceString) && this._state.isRevealed && this._state.isReplaceRevealed) {