提交 1a4f2adb 编写于 作者: J Jackson Kearl

Re-run clean search view searches on "open in editor" to fetch context lines...

Re-run clean search view searches on "open in editor" to fetch context lines as per searchEditor.defaultContextLines
Set default defaultContextLines to 1.
Close #99321.
上级 a5bc167d
...@@ -854,8 +854,8 @@ configurationRegistry.registerConfiguration({ ...@@ -854,8 +854,8 @@ configurationRegistry.registerConfiguration({
}, },
'search.searchEditor.defaultNumberOfContextLines': { 'search.searchEditor.defaultNumberOfContextLines': {
type: ['number', 'null'], type: ['number', 'null'],
default: null, default: 1,
markdownDescription: nls.localize('search.searchEditor.defaultNumberOfContextLines', "The default number of surrounding context lines to use when creating new Search Editors with `Search Editor: Open new Search Editor` and `Search Editor: Open new Search Editor to the Side`. If defined, this overrides `#search.searchEditor.reusePriorSearchConfiguration#`.") markdownDescription: nls.localize('search.searchEditor.defaultNumberOfContextLines', "The default number of surrounding context lines to use when creating new Search Editors. If using `#search.searchEditor.reusePriorSearchConfiguration#`, this can be set to `null` (empty) to use the prior Search Editor's configuration.")
}, },
'search.sortOrder': { 'search.sortOrder': {
'type': 'string', 'type': 'string',
......
...@@ -355,7 +355,7 @@ export class SearchWidget extends Widget { ...@@ -355,7 +355,7 @@ export class SearchWidget extends Widget {
if (options.showContextToggle) { if (options.showContextToggle) {
this.contextLinesInput = new InputBox(searchInputContainer, this.contextViewService, { type: 'number' }); this.contextLinesInput = new InputBox(searchInputContainer, this.contextViewService, { type: 'number' });
dom.addClass(this.contextLinesInput.element, 'context-lines-input'); dom.addClass(this.contextLinesInput.element, 'context-lines-input');
this.contextLinesInput.value = '2'; this.contextLinesInput.value = '' + (this.configurationService.getValue<ISearchConfigurationProperties>('search').searchEditor.defaultNumberOfContextLines ?? 1);
this._register(this.contextLinesInput.onDidChange(() => this.onContextLinesChanged())); this._register(this.contextLinesInput.onDidChange(() => this.onContextLinesChanged()));
this._register(attachInputBoxStyler(this.contextLinesInput, this.themeService)); this._register(attachInputBoxStyler(this.contextLinesInput, this.themeService));
dom.append(searchInputContainer, this.showContextCheckbox.domNode); dom.append(searchInputContainer, this.showContextCheckbox.domNode);
......
...@@ -164,6 +164,7 @@ export const createEditorFromSearchResult = ...@@ -164,6 +164,7 @@ export const createEditorFromSearchResult =
const telemetryService = accessor.get(ITelemetryService); const telemetryService = accessor.get(ITelemetryService);
const instantiationService = accessor.get(IInstantiationService); const instantiationService = accessor.get(IInstantiationService);
const labelService = accessor.get(ILabelService); const labelService = accessor.get(ILabelService);
const configurationService = accessor.get(IConfigurationService);
telemetryService.publicLog2('searchEditor/createEditorFromSearchResult'); telemetryService.publicLog2('searchEditor/createEditorFromSearchResult');
...@@ -171,8 +172,15 @@ export const createEditorFromSearchResult = ...@@ -171,8 +172,15 @@ export const createEditorFromSearchResult =
const labelFormatter = (uri: URI): string => labelService.getUriLabel(uri, { relative: true }); const labelFormatter = (uri: URI): string => labelService.getUriLabel(uri, { relative: true });
const { text, matchRanges, config } = serializeSearchResultForEditor(searchResult, rawIncludePattern, rawExcludePattern, 0, labelFormatter); const { text, matchRanges, config } = serializeSearchResultForEditor(searchResult, rawIncludePattern, rawExcludePattern, 0, labelFormatter);
const contextLines = configurationService.getValue<ISearchConfigurationProperties>('search').searchEditor.defaultNumberOfContextLines;
const input = instantiationService.invokeFunction(getOrMakeSearchEditorInput, { text, config }); if (searchResult.isDirty || contextLines === 0 || contextLines === null) {
await editorService.openEditor(input, { pinned: true }); const input = instantiationService.invokeFunction(getOrMakeSearchEditorInput, { text, config });
input.setMatchRanges(matchRanges); await editorService.openEditor(input, { pinned: true });
input.setMatchRanges(matchRanges);
} else {
const input = instantiationService.invokeFunction(getOrMakeSearchEditorInput, { text: '', config: { ...config, contextLines } });
const editor = await editorService.openEditor(input, { pinned: true }) as SearchEditor;
editor.triggerSearch({ focusResults: true });
}
}; };
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册