提交 49df04e8 编写于 作者: R Rob Lourens

Restore previous behavior of cmd+shift+F triggering a

search with the selected text, except not when a result has been
removed by the user
For #91901
上级 416bb2e8
......@@ -145,7 +145,7 @@ export abstract class FindOrReplaceInFilesAction extends Action {
const searchAndReplaceWidget = openedView.searchAndReplaceWidget;
searchAndReplaceWidget.toggleReplace(this.expandSearchReplaceWidget);
const updatedText = openedView.updateTextFromSelection(!this.expandSearchReplaceWidget);
const updatedText = openedView.updateTextFromSelection({ allowUnselectedWord: !this.expandSearchReplaceWidget });
openedView.searchAndReplaceWidget.focus(undefined, updatedText, updatedText);
}
});
......@@ -172,7 +172,7 @@ export const FindInFilesCommand: ICommandHandler = (accessor, args: IFindInFiles
if (typeof args.query === 'string') {
openedView.setSearchParameters(args);
} else {
updatedText = openedView.updateTextFromSelection((typeof args.replace !== 'string'));
updatedText = openedView.updateTextFromSelection({ allowUnselectedWord: typeof args.replace !== 'string' });
}
openedView.searchAndReplaceWidget.focus(undefined, updatedText, updatedText);
}
......
......@@ -867,11 +867,11 @@ export class SearchView extends ViewPane {
focus(): void {
super.focus();
const updatedText = this.updateTextFromSelection();
const updatedText = this.updateTextFromSelection({ allowSearchOnType: false });
this.searchWidget.focus(undefined, undefined, updatedText);
}
updateTextFromSelection(allowUnselectedWord = true): boolean {
updateTextFromSelection({ allowUnselectedWord = true, allowSearchOnType = true }): boolean {
let updatedText = false;
const seedSearchStringFromSelection = this.configurationService.getValue<IEditorOptions>('editor').find!.seedSearchStringFromSelection;
if (seedSearchStringFromSelection) {
......@@ -880,9 +880,14 @@ export class SearchView extends ViewPane {
if (this.searchWidget.searchInput.getRegex()) {
selectedText = strings.escapeRegExpCharacters(selectedText);
}
this.pauseSearching = true;
this.searchWidget.setValue(selectedText);
this.pauseSearching = false;
if (allowSearchOnType && !this.viewModel.searchResult.hasRemovedResults) {
this.searchWidget.setValue(selectedText);
} else {
this.pauseSearching = true;
this.searchWidget.setValue(selectedText);
this.pauseSearching = false;
}
updatedText = true;
}
}
......
......@@ -703,6 +703,8 @@ export class SearchResult extends Disposable {
private _rangeHighlightDecorations: RangeHighlightDecorations;
private disposePastResults: () => void = () => { };
private _hasRemovedResults = false;
constructor(
private _searchModel: SearchModel,
@IReplaceService private readonly replaceService: IReplaceService,
......@@ -714,6 +716,16 @@ export class SearchResult extends Disposable {
this._rangeHighlightDecorations = this.instantiationService.createInstance(RangeHighlightDecorations);
this._register(this.modelService.onModelAdded(model => this.onModelAdded(model)));
this._register(this.onChange(e => {
if (e.removed) {
this._hasRemovedResults = true;
}
}));
}
get hasRemovedResults(): boolean {
return this._hasRemovedResults;
}
get query(): ITextQuery | null {
......@@ -725,7 +737,8 @@ export class SearchResult extends Disposable {
const oldFolderMatches = this.folderMatches();
new Promise(resolve => this.disposePastResults = resolve)
.then(() => oldFolderMatches.forEach(match => match.clear()))
.then(() => oldFolderMatches.forEach(match => match.dispose()));
.then(() => oldFolderMatches.forEach(match => match.dispose()))
.then(() => this._hasRemovedResults = false);
this._rangeHighlightDecorations.removeHighlightRange();
this._folderMatchesMap = TernarySearchTree.forPaths<FolderMatchWithResource>();
......@@ -1028,7 +1041,6 @@ export class SearchModel extends Disposable {
search(query: ITextQuery, onProgress?: (result: ISearchProgressItem) => void): Promise<ISearchComplete> {
this.cancelSearch(true);
this._searchQuery = query;
if (!this.searchConfig.searchOnType) {
this.searchResult.clear();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册