From 82ec0a3fa9fda562351426af6509e4fa1b291597 Mon Sep 17 00:00:00 2001 From: rebornix Date: Wed, 12 Apr 2023 10:03:02 -0700 Subject: [PATCH] Experiment turning all cells into editing mode on replace --- .../notebook/browser/contrib/find/findModel.ts | 15 ++++++++++++++- .../contrib/search/browser/searchWidget.ts | 8 ++++---- 2 files changed, 18 insertions(+), 5 deletions(-) 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 8e1309730fff9..3c65db14c7c3e 100644 --- a/src/vs/workbench/contrib/notebook/browser/contrib/find/findModel.ts +++ b/src/vs/workbench/contrib/notebook/browser/contrib/find/findModel.ts @@ -17,6 +17,7 @@ import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/no import { CancellationToken } from 'vs/base/common/cancellation'; import { NotebookFindFilters } from 'vs/workbench/contrib/notebook/browser/contrib/find/findFilters'; import { FindMatchDecorationModel } from 'vs/workbench/contrib/notebook/browser/contrib/find/findMatchDecorationModel'; +import { NotebookViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/notebookViewModelImpl'; export class CellFindMatchModel implements CellFindMatchWithIndex { readonly cell: ICellViewModel; @@ -84,7 +85,19 @@ export class FindModel extends Disposable { this._computePromise = null; this._register(_state.onFindReplaceStateChange(e => { - if (e.searchString || e.isRegex || e.matchCase || e.searchScope || e.wholeWord || (e.isRevealed && this._state.isRevealed) || e.filters) { + if (e.isReplaceRevealed) { + const viewModel = this._notebookEditor._getViewModel() as NotebookViewModel | undefined; + if (viewModel) { + for (let i = 0; i < viewModel.length; i++) { + const cell = viewModel.cellAt(i); + if (cell && cell.cellKind === CellKind.Markup) { + cell.updateEditState(this._state.isReplaceRevealed ? CellEditState.Editing : CellEditState.Preview, 'Find'); + } + } + } + } + + if (e.searchString || e.isRegex || e.matchCase || e.searchScope || e.wholeWord || (e.isRevealed && this._state.isRevealed) || e.filters || e.isReplaceRevealed) { this.research(); } diff --git a/src/vs/workbench/contrib/search/browser/searchWidget.ts b/src/vs/workbench/contrib/search/browser/searchWidget.ts index af8eeca5a97db..6998e76429fd7 100644 --- a/src/vs/workbench/contrib/search/browser/searchWidget.ts +++ b/src/vs/workbench/contrib/search/browser/searchWidget.ts @@ -191,10 +191,10 @@ export class SearchWidget extends Widget { this._notebookFilters = this._register( new NotebookFindFilters( false, - options.notebookOptions?.isInNotebookMarkdownInput ?? true, - !options.notebookOptions?.isInNotebookMarkdownInput ?? false, - options.notebookOptions?.isInNotebookCellInput ?? true, - options.notebookOptions?.isInNotebookCellOutput ?? false + notebookOptions?.isInNotebookMarkdownInput ?? true, + !notebookOptions?.isInNotebookMarkdownInput ?? false, + notebookOptions?.isInNotebookCellInput ?? true, + notebookOptions?.isInNotebookCellOutput ?? false )); this._register(