Skip to content

Commit

Permalink
Experiment turning all cells into editing mode on replace
Browse files Browse the repository at this point in the history
  • Loading branch information
rebornix committed Apr 12, 2023
1 parent 2cd3cf8 commit 82ec0a3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}

Expand Down
8 changes: 4 additions & 4 deletions src/vs/workbench/contrib/search/browser/searchWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 82ec0a3

Please sign in to comment.