提交 4c41eca2 编写于 作者: R Rob Lourens

"Use exclude settings" button to control using search.exclude and files.exclude

上级 16d82e7d
...@@ -37,6 +37,7 @@ export interface IQueryOptions { ...@@ -37,6 +37,7 @@ export interface IQueryOptions {
fileEncoding?: string; fileEncoding?: string;
useRipgrep?: boolean; useRipgrep?: boolean;
useIgnoreFiles?: boolean; useIgnoreFiles?: boolean;
useExcludeSettings?: boolean;
} }
export interface ISearchQuery extends IQueryOptions { export interface ISearchQuery extends IQueryOptions {
......
...@@ -310,6 +310,15 @@ ...@@ -310,6 +310,15 @@
background-size: 18px 18px; background-size: 18px 18px;
} }
.vs .monaco-workbench .search-viewlet .query-details .file-types .controls>.custom-checkbox.useExcludeSettings {
background: url('configure.svg') center center no-repeat;
}
.vs-dark .monaco-workbench .search-viewlet .query-details .file-types .controls>.custom-checkbox.useExcludeSettings,
.hc-black .monaco-workbench .search-viewlet .query-details .file-types .controls>.custom-checkbox.useExcludeSettings {
background: url('configure-inverse.svg') center center no-repeat;
}
.search-viewlet .findInFileMatch, .search-viewlet .findInFileMatch,
.monaco-editor .findInFileMatch { .monaco-editor .findInFileMatch {
background-color: rgba(234, 92, 0, 0.3); background-color: rgba(234, 92, 0, 0.3);
......
...@@ -31,22 +31,21 @@ export class PatternInputWidget extends Widget { ...@@ -31,22 +31,21 @@ export class PatternInputWidget extends Widget {
public inputFocusTracker: dom.IFocusTracker; public inputFocusTracker: dom.IFocusTracker;
private onOptionChange: (event: Event) => void; protected onOptionChange: (event: Event) => void;
private width: number; private width: number;
private placeholder: string; private placeholder: string;
private ariaLabel: string; private ariaLabel: string;
private pattern: Checkbox; private pattern: Checkbox;
private useIgnoreFilesBox: Checkbox;
private domNode: HTMLElement; private domNode: HTMLElement;
private inputNode: HTMLInputElement; private inputNode: HTMLInputElement;
private inputBox: InputBox; protected inputBox: InputBox;
private _onSubmit = this._register(new Emitter<boolean>()); private _onSubmit = this._register(new Emitter<boolean>());
public onSubmit: CommonEvent<boolean> = this._onSubmit.event; public onSubmit: CommonEvent<boolean> = this._onSubmit.event;
constructor(parent: HTMLElement, private contextViewProvider: IContextViewProvider, private themeService: IThemeService, options: IOptions = Object.create(null), private showUseIgnoreFiles = false) { constructor(parent: HTMLElement, private contextViewProvider: IContextViewProvider, private themeService: IThemeService, options: IOptions = Object.create(null)) {
super(); super();
this.onOptionChange = null; this.onOptionChange = null;
this.width = options.width || 100; this.width = options.width || 100;
...@@ -54,7 +53,6 @@ export class PatternInputWidget extends Widget { ...@@ -54,7 +53,6 @@ export class PatternInputWidget extends Widget {
this.ariaLabel = options.ariaLabel || nls.localize('defaultLabel', "input"); this.ariaLabel = options.ariaLabel || nls.localize('defaultLabel', "input");
this.pattern = null; this.pattern = null;
this.useIgnoreFilesBox = null;
this.domNode = null; this.domNode = null;
this.inputNode = null; this.inputNode = null;
this.inputBox = null; this.inputBox = null;
...@@ -67,7 +65,6 @@ export class PatternInputWidget extends Widget { ...@@ -67,7 +65,6 @@ export class PatternInputWidget extends Widget {
public dispose(): void { public dispose(): void {
super.dispose(); super.dispose();
this.pattern.dispose(); this.pattern.dispose();
this.useIgnoreFilesBox.dispose();
if (this.inputFocusTracker) { if (this.inputFocusTracker) {
this.inputFocusTracker.dispose(); this.inputFocusTracker.dispose();
} }
...@@ -141,27 +138,20 @@ export class PatternInputWidget extends Widget { ...@@ -141,27 +138,20 @@ export class PatternInputWidget extends Widget {
return this.inputBox.hasFocus(); return this.inputBox.hasFocus();
} }
public useIgnoreFiles(): boolean {
return this.useIgnoreFilesBox.checked;
}
public setUseIgnoreFiles(value: boolean): void {
this.useIgnoreFilesBox.checked = value;
this.setInputWidth();
}
public isGlobPattern(): boolean { public isGlobPattern(): boolean {
return this.pattern.checked; return this.pattern.checked;
} }
public setIsGlobPattern(value: boolean): void { public setIsGlobPattern(value: boolean): void {
this.pattern.checked = value; this.pattern.checked = value;
this.setInputWidth();
} }
private setInputWidth(): void { private setInputWidth(): void {
let w = this.width - this.pattern.width() - this.useIgnoreFilesBox.width(); this.inputBox.width = this.width - this.getSubcontrolsWidth();
this.inputBox.width = w; }
protected getSubcontrolsWidth(): number {
return this.pattern.width();
} }
private render(): void { private render(): void {
...@@ -190,7 +180,6 @@ export class PatternInputWidget extends Widget { ...@@ -190,7 +180,6 @@ export class PatternInputWidget extends Widget {
if (!viaKeyboard) { if (!viaKeyboard) {
this.inputBox.focus(); this.inputBox.focus();
} }
this.setInputWidth();
if (this.isGlobPattern()) { if (this.isGlobPattern()) {
this.showGlobHelp(); this.showGlobHelp();
...@@ -200,19 +189,6 @@ export class PatternInputWidget extends Widget { ...@@ -200,19 +189,6 @@ export class PatternInputWidget extends Widget {
} }
}); });
this.useIgnoreFilesBox = new Checkbox({
actionClassName: 'useIgnoreFiles',
title: nls.localize('useIgnoreFilesDescription', "Use Ignore Files"),
isChecked: false,
onChange: (viaKeyboard) => {
this.onOptionChange(null);
if (!viaKeyboard) {
this.inputBox.focus();
}
this.setInputWidth();
}
});
$(this.pattern.domNode).on('mouseover', () => { $(this.pattern.domNode).on('mouseover', () => {
if (this.isGlobPattern()) { if (this.isGlobPattern()) {
this.showGlobHelp(); this.showGlobHelp();
...@@ -223,17 +199,16 @@ export class PatternInputWidget extends Widget { ...@@ -223,17 +199,16 @@ export class PatternInputWidget extends Widget {
this.inputBox.hideMessage(); this.inputBox.hideMessage();
}); });
this.setInputWidth();
let controls = document.createElement('div'); let controls = document.createElement('div');
controls.className = 'controls'; controls.className = 'controls';
if (this.showUseIgnoreFiles) { this.renderSubcontrols(controls);
controls.appendChild(this.useIgnoreFilesBox.domNode);
}
controls.appendChild(this.pattern.domNode);
this.domNode.appendChild(controls); this.domNode.appendChild(controls);
this.setInputWidth();
}
protected renderSubcontrols(controlsDiv: HTMLDivElement): void {
controlsDiv.appendChild(this.pattern.domNode);
} }
private showGlobHelp(): void { private showGlobHelp(): void {
...@@ -255,4 +230,66 @@ export class PatternInputWidget extends Widget { ...@@ -255,4 +230,66 @@ export class PatternInputWidget extends Widget {
return; return;
} }
} }
}
export class ExcludePatternInputWidget extends PatternInputWidget {
private useIgnoreFilesBox: Checkbox;
private useExcludeSettingsBox: Checkbox;
public dispose(): void {
super.dispose();
this.useIgnoreFilesBox.dispose();
this.useExcludeSettingsBox.dispose();
}
public useExcludeSettings(): boolean {
return this.useExcludeSettingsBox.checked;
}
public setUseExcludeSettings(value: boolean) {
this.useExcludeSettingsBox.checked = value;
}
public useIgnoreFiles(): boolean {
return this.useIgnoreFilesBox.checked;
}
public setUseIgnoreFiles(value: boolean): void {
this.useIgnoreFilesBox.checked = value;
}
protected getSubcontrolsWidth(): number {
return super.getSubcontrolsWidth() + this.useIgnoreFilesBox.width() + this.useExcludeSettingsBox.width();
}
protected renderSubcontrols(controlsDiv: HTMLDivElement): void {
this.useIgnoreFilesBox = new Checkbox({
actionClassName: 'useIgnoreFiles',
title: nls.localize('useIgnoreFilesDescription', "Use Ignore Files"),
isChecked: false,
onChange: (viaKeyboard) => {
this.onOptionChange(null);
if (!viaKeyboard) {
this.inputBox.focus();
}
}
});
this.useExcludeSettingsBox = new Checkbox({
actionClassName: 'useExcludeSettings',
title: nls.localize('useExcludeSettingsDescription', "Use Exclude Settings"),
isChecked: false,
onChange: (viaKeyboard) => {
this.onOptionChange(null);
if (!viaKeyboard) {
this.inputBox.focus();
}
}
});
controlsDiv.appendChild(this.useIgnoreFilesBox.domNode);
controlsDiv.appendChild(this.useExcludeSettingsBox.domNode);
super.renderSubcontrols(controlsDiv);
}
} }
\ No newline at end of file
...@@ -48,7 +48,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; ...@@ -48,7 +48,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey'; import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { KeyCode } from 'vs/base/common/keyCodes'; import { KeyCode } from 'vs/base/common/keyCodes';
import { PatternInputWidget } from 'vs/workbench/parts/search/browser/patternInputWidget'; import { PatternInputWidget, ExcludePatternInputWidget } from 'vs/workbench/parts/search/browser/patternInputWidget';
import { SearchRenderer, SearchDataSource, SearchSorter, SearchController, SearchAccessibilityProvider, SearchFilter } from 'vs/workbench/parts/search/browser/searchResultsView'; import { SearchRenderer, SearchDataSource, SearchSorter, SearchController, SearchAccessibilityProvider, SearchFilter } from 'vs/workbench/parts/search/browser/searchResultsView';
import { SearchWidget } from 'vs/workbench/parts/search/browser/searchWidget'; import { SearchWidget } from 'vs/workbench/parts/search/browser/searchWidget';
import { RefreshAction, CollapseAllAction, ClearSearchResultsAction, ConfigureGlobalExclusionsAction } from 'vs/workbench/parts/search/browser/searchActions'; import { RefreshAction, CollapseAllAction, ClearSearchResultsAction, ConfigureGlobalExclusionsAction } from 'vs/workbench/parts/search/browser/searchActions';
...@@ -86,7 +86,7 @@ export class SearchViewlet extends Viewlet { ...@@ -86,7 +86,7 @@ export class SearchViewlet extends Viewlet {
private searchWidget: SearchWidget; private searchWidget: SearchWidget;
private size: Dimension; private size: Dimension;
private queryDetails: HTMLElement; private queryDetails: HTMLElement;
private inputPatternExclusions: PatternInputWidget; private inputPatternExclusions: ExcludePatternInputWidget;
private inputPatternGlobalExclusions: InputBox; private inputPatternGlobalExclusions: InputBox;
private inputPatternGlobalExclusionsContainer: Builder; private inputPatternGlobalExclusionsContainer: Builder;
private inputPatternIncludes: PatternInputWidget; private inputPatternIncludes: PatternInputWidget;
...@@ -167,6 +167,9 @@ export class SearchViewlet extends Viewlet { ...@@ -167,6 +167,9 @@ export class SearchViewlet extends Viewlet {
const useIgnoreFiles = typeof this.viewletSettings['query.useIgnoreFiles'] === 'boolean' ? const useIgnoreFiles = typeof this.viewletSettings['query.useIgnoreFiles'] === 'boolean' ?
this.viewletSettings['query.useIgnoreFiles'] : this.viewletSettings['query.useIgnoreFiles'] :
this.configurationService.getConfiguration<ISearchConfiguration>().search.useIgnoreFilesByDefault; this.configurationService.getConfiguration<ISearchConfiguration>().search.useIgnoreFilesByDefault;
const useExcludeSettings = typeof this.viewletSettings['query.useExcludeSettings'] === 'boolean' ?
this.viewletSettings['query.useExcludeSettings'] :
true;
this.queryDetails = this.searchWidgetsContainer.div({ 'class': ['query-details'] }, (builder) => { this.queryDetails = this.searchWidgetsContainer.div({ 'class': ['query-details'] }, (builder) => {
builder.div({ 'class': 'more', 'tabindex': 0, 'role': 'button', 'title': nls.localize('moreSearch', "Toggle Search Details") }) builder.div({ 'class': 'more', 'tabindex': 0, 'role': 'button', 'title': nls.localize('moreSearch', "Toggle Search Details") })
...@@ -208,14 +211,14 @@ export class SearchViewlet extends Viewlet { ...@@ -208,14 +211,14 @@ export class SearchViewlet extends Viewlet {
let title = nls.localize('searchScope.excludes', "files to exclude"); let title = nls.localize('searchScope.excludes', "files to exclude");
builder.element('h4', { text: title }); builder.element('h4', { text: title });
const configuration = this.configurationService.getConfiguration<ISearchConfiguration>(); this.inputPatternExclusions = new ExcludePatternInputWidget(builder.getContainer(), this.contextViewService, this.themeService, {
this.inputPatternExclusions = new PatternInputWidget(builder.getContainer(), this.contextViewService, this.themeService, {
ariaLabel: nls.localize('label.excludes', 'Search Exclude Patterns') ariaLabel: nls.localize('label.excludes', 'Search Exclude Patterns')
}, configuration.search.useRipgrep); });
this.inputPatternExclusions.setIsGlobPattern(exclusionsUsePattern); this.inputPatternExclusions.setIsGlobPattern(exclusionsUsePattern);
this.inputPatternExclusions.setValue(patternExclusions); this.inputPatternExclusions.setValue(patternExclusions);
this.inputPatternExclusions.setUseIgnoreFiles(useIgnoreFiles); this.inputPatternExclusions.setUseIgnoreFiles(useIgnoreFiles);
this.inputPatternExclusions.setUseExcludeSettings(useExcludeSettings);
this.inputPatternExclusions this.inputPatternExclusions
.on(FindInput.OPTION_CHANGE, (e) => { .on(FindInput.OPTION_CHANGE, (e) => {
...@@ -908,6 +911,7 @@ export class SearchViewlet extends Viewlet { ...@@ -908,6 +911,7 @@ export class SearchViewlet extends Viewlet {
const patternIncludes = this.inputPatternIncludes.getValue().trim(); const patternIncludes = this.inputPatternIncludes.getValue().trim();
const includesUsePattern = this.inputPatternIncludes.isGlobPattern(); const includesUsePattern = this.inputPatternIncludes.isGlobPattern();
const useIgnoreFiles = this.inputPatternExclusions.useIgnoreFiles(); const useIgnoreFiles = this.inputPatternExclusions.useIgnoreFiles();
const useExcludeSettings = this.inputPatternExclusions.useExcludeSettings();
// store memento // store memento
this.viewletSettings['query.contentPattern'] = contentPattern; this.viewletSettings['query.contentPattern'] = contentPattern;
...@@ -919,6 +923,7 @@ export class SearchViewlet extends Viewlet { ...@@ -919,6 +923,7 @@ export class SearchViewlet extends Viewlet {
this.viewletSettings['query.folderIncludes'] = patternIncludes; this.viewletSettings['query.folderIncludes'] = patternIncludes;
this.viewletSettings['query.includesUsePattern'] = includesUsePattern; this.viewletSettings['query.includesUsePattern'] = includesUsePattern;
this.viewletSettings['query.useIgnoreFiles'] = useIgnoreFiles; this.viewletSettings['query.useIgnoreFiles'] = useIgnoreFiles;
this.viewletSettings['query.useExcludeSettings'] = useExcludeSettings;
if (!rerunQuery) { if (!rerunQuery) {
return; return;
...@@ -942,23 +947,24 @@ export class SearchViewlet extends Viewlet { ...@@ -942,23 +947,24 @@ export class SearchViewlet extends Viewlet {
} }
} }
let content = { const content = {
pattern: contentPattern, pattern: contentPattern,
isRegExp: isRegex, isRegExp: isRegex,
isCaseSensitive: isCaseSensitive, isCaseSensitive: isCaseSensitive,
isWordMatch: isWholeWords isWordMatch: isWholeWords
}; };
let excludes: IExpression = this.inputPatternExclusions.getGlob(); const excludes: IExpression = this.inputPatternExclusions.getGlob();
let includes: IExpression = this.inputPatternIncludes.getGlob(); const includes: IExpression = this.inputPatternIncludes.getGlob();
let options: IQueryOptions = { const options: IQueryOptions = {
folderResources: this.contextService.hasWorkspace() ? [this.contextService.getWorkspace().resource] : [], folderResources: this.contextService.hasWorkspace() ? [this.contextService.getWorkspace().resource] : [],
extraFileResources: getOutOfWorkspaceEditorResources(this.editorGroupService, this.contextService), extraFileResources: getOutOfWorkspaceEditorResources(this.editorGroupService, this.contextService),
excludePattern: excludes, excludePattern: excludes,
maxResults: SearchViewlet.MAX_TEXT_RESULTS, maxResults: SearchViewlet.MAX_TEXT_RESULTS,
includePattern: includes, includePattern: includes,
useIgnoreFiles useIgnoreFiles,
useExcludeSettings
}; };
this.onQueryTriggered(this.queryBuilder.text(content, options), patternExcludes, patternIncludes); this.onQueryTriggered(this.queryBuilder.text(content, options), patternExcludes, patternIncludes);
......
...@@ -24,11 +24,13 @@ export class QueryBuilder { ...@@ -24,11 +24,13 @@ export class QueryBuilder {
private query(type: QueryType, contentPattern: IPatternInfo, options: IQueryOptions = {}): ISearchQuery { private query(type: QueryType, contentPattern: IPatternInfo, options: IQueryOptions = {}): ISearchQuery {
const configuration = this.configurationService.getConfiguration<ISearchConfiguration>(); const configuration = this.configurationService.getConfiguration<ISearchConfiguration>();
const excludePattern = getExcludes(configuration); const settingsExcludePattern = getExcludes(configuration);
if (!options.excludePattern) { if (options.useExcludeSettings) {
options.excludePattern = excludePattern; if (options.excludePattern) {
} else { mixin(options.excludePattern, settingsExcludePattern, false /* no overwrite */);
mixin(options.excludePattern, excludePattern, false /* no overwrite */); } else {
options.excludePattern = settingsExcludePattern;
}
} }
return { return {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册