mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-27 02:27:53 +01:00
Used FileMathOrMatch for putting multicursor for search result
This commit is contained in:
@@ -632,17 +632,9 @@ export class MultiCursorSelectionController extends Disposable implements IEdito
|
||||
}
|
||||
}
|
||||
|
||||
public selectAllUsingString(searchString: string, isRegex: boolean, matchCase: boolean, wholeWord: boolean, limitResultCount?: number): void {
|
||||
if (!this._editor.hasModel()) {
|
||||
return;
|
||||
}
|
||||
|
||||
let matches: FindMatch[] | null = null;
|
||||
|
||||
matches = this._editor.getModel().findMatches(searchString, true, isRegex, matchCase, wholeWord ? this._editor.getOption(EditorOption.wordSeparators) : null, false, Constants.MAX_SAFE_SMALL_INTEGER);
|
||||
|
||||
if (matches.length > 0) {
|
||||
this._setSelections(matches.map(m => new Selection(m.range.startLineNumber, m.range.startColumn, m.range.endLineNumber, m.range.endColumn)));
|
||||
public selectAllUsingSelections(selections: Selection[]): void {
|
||||
if (selections.length > 0) {
|
||||
this._setSelections(selections);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,6 +62,7 @@ import { Memento, MementoObject } from 'vs/workbench/common/memento';
|
||||
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
|
||||
import { IOpenerService } from 'vs/platform/opener/common/opener';
|
||||
import { MultiCursorSelectionController } from 'vs/editor/contrib/multicursor/multicursor';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
|
||||
const $ = dom.$;
|
||||
|
||||
@@ -1561,15 +1562,21 @@ export class SearchView extends ViewletPanel {
|
||||
}
|
||||
}).then(editor => {
|
||||
if (editor) {
|
||||
let codeEditor = getCodeEditor(editor.getControl());
|
||||
if (codeEditor) {
|
||||
let multiCursorController = MultiCursorSelectionController.get(codeEditor);
|
||||
let isRegex = this.searchWidget.searchInput.getRegex();
|
||||
let isWholeWords = this.searchWidget.searchInput.getWholeWords();
|
||||
let isCaseSensitive = this.searchWidget.searchInput.getCaseSensitive();
|
||||
let contentPattern = this.searchWidget.searchInput.getValue();
|
||||
let fileMatch = null;
|
||||
if (element instanceof FileMatch) {
|
||||
fileMatch = element;
|
||||
}
|
||||
else if (element instanceof Match) {
|
||||
fileMatch = element.parent();
|
||||
}
|
||||
|
||||
multiCursorController.selectAllUsingString(contentPattern, isRegex, isCaseSensitive, isWholeWords);
|
||||
if (fileMatch) {
|
||||
const selections = fileMatch.matches().map(m => new Selection(m.range().startLineNumber, m.range().startColumn, m.range().endLineNumber, m.range().endColumn));
|
||||
const codeEditor = getCodeEditor(editor.getControl());
|
||||
if (codeEditor) {
|
||||
let multiCursorController = MultiCursorSelectionController.get(codeEditor);
|
||||
multiCursorController.selectAllUsingSelections(selections);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.viewModel.searchResult.rangeHighlightDecorations.removeHighlightRange();
|
||||
|
||||
Reference in New Issue
Block a user