Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Focus in Quick Search doesn't go back to previous position after hitting ESC when zero results #203073

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export class TextSearchQuickAccess extends PickerQuickAccessProvider<ITextSearch
results: [],
messages: []
});
private storedOriginalLocation = false;
private readonly editorViewState = new EditorViewState(
this._editorService
);
Expand Down Expand Up @@ -102,6 +101,7 @@ export class TextSearchQuickAccess extends PickerQuickAccessProvider<ITextSearch
}
picker.customButton = true;
picker.customLabel = '$(link-external)';
this.editorViewState.reset();
disposables.add(picker.onDidCustom(() => {
if (this.searchModel.searchResult.count() > 0) {
this.moveToSearchViewlet(undefined);
Expand All @@ -114,12 +114,8 @@ export class TextSearchQuickAccess extends PickerQuickAccessProvider<ITextSearch
const [item] = picker.activeItems;

if (item?.match) {
// only store location once, or else it will store new state every time we change active pick
if (!this.storedOriginalLocation) {
// we must remember our curret view state to be able to restore
this.editorViewState.set();
this.storedOriginalLocation = true;
}
// we must remember our curret view state to be able to restore (will automatically track if there is already stored state)
this.editorViewState.set();
// open it
this._editorService.openEditor({
resource: item.match.parent().resource,
Expand Down Expand Up @@ -176,6 +172,7 @@ export class TextSearchQuickAccess extends PickerQuickAccessProvider<ITextSearch
const content: IPatternInfo = {
pattern: contentPattern,
};
this.searchModel.searchResult.toggleHighlights(false);
const charsPerLine = content.isRegExp ? 10000 : 1000; // from https://github.com/microsoft/vscode/blob/e7ad5651ac26fa00a40aa1e4010e81b92f655569/src/vs/workbench/contrib/search/browser/searchView.ts#L1508

const query: ITextQuery = this.queryBuilder.text(content, folderResources.map(folder => folder.uri), this._getTextQueryBuilderOptions(charsPerLine));
Expand Down