mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-31 01:00:29 -04:00
Merge from vscode 3d67364fbfcf676d93be64f949e9b33e7f1b969e (#5028)
This commit is contained in:
@@ -48,7 +48,7 @@ export class OpenSettings2Action extends Action {
|
||||
}
|
||||
|
||||
run(event?: any): Promise<any> {
|
||||
return this.preferencesService.openSettings(false);
|
||||
return this.preferencesService.openSettings(false, undefined);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ export class OpenSettingsJsonAction extends Action {
|
||||
}
|
||||
|
||||
run(event?: any): Promise<any> {
|
||||
return this.preferencesService.openSettings(true);
|
||||
return this.preferencesService.openSettings(true, undefined);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -256,8 +256,8 @@ export class PreferencesEditor extends BaseEditor {
|
||||
}
|
||||
const promise: Promise<boolean> = this.input && this.input.isDirty() ? this.input.save() : Promise.resolve(true);
|
||||
promise.then(() => {
|
||||
if (target === ConfigurationTarget.USER) {
|
||||
this.preferencesService.switchSettings(ConfigurationTarget.USER, this.preferencesService.userSettingsResource, true);
|
||||
if (target === ConfigurationTarget.USER_LOCAL) {
|
||||
this.preferencesService.switchSettings(ConfigurationTarget.USER_LOCAL, this.preferencesService.userSettingsResource, true);
|
||||
} else if (target === ConfigurationTarget.WORKSPACE) {
|
||||
this.preferencesService.switchSettings(ConfigurationTarget.WORKSPACE, this.preferencesService.workspaceSettingsResource!, true);
|
||||
} else if (target instanceof URI) {
|
||||
@@ -507,7 +507,7 @@ class PreferencesRenderersController extends Disposable {
|
||||
private searchAllSettingsTargets(query: string, searchProvider: ISearchProvider, groupId: string, groupLabel: string, groupOrder: number, token?: CancellationToken): Promise<void> {
|
||||
const searchPs = [
|
||||
this.searchSettingsTarget(query, searchProvider, ConfigurationTarget.WORKSPACE, groupId, groupLabel, groupOrder, token),
|
||||
this.searchSettingsTarget(query, searchProvider, ConfigurationTarget.USER, groupId, groupLabel, groupOrder, token)
|
||||
this.searchSettingsTarget(query, searchProvider, ConfigurationTarget.USER_LOCAL, groupId, groupLabel, groupOrder, token)
|
||||
];
|
||||
|
||||
for (const folder of this.workspaceContextService.getWorkspace().folders) {
|
||||
@@ -541,9 +541,10 @@ class PreferencesRenderersController extends Disposable {
|
||||
}
|
||||
|
||||
private async getPreferencesEditorModel(target: SettingsTarget | undefined): Promise<ISettingsEditorModel | undefined> {
|
||||
const resource = target === ConfigurationTarget.USER ? this.preferencesService.userSettingsResource :
|
||||
target === ConfigurationTarget.WORKSPACE ? this.preferencesService.workspaceSettingsResource :
|
||||
target;
|
||||
const resource = target === ConfigurationTarget.USER_LOCAL ? this.preferencesService.userSettingsResource :
|
||||
target === ConfigurationTarget.USER_REMOTE ? this.preferencesService.userSettingsResource :
|
||||
target === ConfigurationTarget.WORKSPACE ? this.preferencesService.workspaceSettingsResource :
|
||||
target;
|
||||
|
||||
if (!resource) {
|
||||
return undefined;
|
||||
@@ -821,7 +822,7 @@ class SideBySidePreferencesWidget extends Widget {
|
||||
|
||||
this.editablePreferencesEditorContainer = DOM.$('.editable-preferences-editor-container');
|
||||
const editablePreferencesHeaderContainer = DOM.append(this.editablePreferencesEditorContainer, DOM.$('.preferences-header-container'));
|
||||
this.settingsTargetsWidget = this._register(this.instantiationService.createInstance(SettingsTargetsWidget, editablePreferencesHeaderContainer));
|
||||
this.settingsTargetsWidget = this._register(this.instantiationService.createInstance(SettingsTargetsWidget, editablePreferencesHeaderContainer, undefined));
|
||||
this._register(this.settingsTargetsWidget.onDidTargetChange(target => this._onDidSettingsTargetChange.fire(target)));
|
||||
|
||||
this._register(attachStylerCallback(this.themeService, { scrollbarShadow }, colors => {
|
||||
@@ -865,7 +866,7 @@ class SideBySidePreferencesWidget extends Widget {
|
||||
|
||||
private getDefaultPreferencesHeaderText(target: ConfigurationTarget): string {
|
||||
switch (target) {
|
||||
case ConfigurationTarget.USER:
|
||||
case ConfigurationTarget.USER_LOCAL:
|
||||
return nls.localize('defaultUserSettings', "Default User Settings");
|
||||
case ConfigurationTarget.WORKSPACE:
|
||||
return nls.localize('defaultWorkspaceSettings', "Default Workspace Settings");
|
||||
@@ -942,7 +943,7 @@ class SideBySidePreferencesWidget extends Widget {
|
||||
|
||||
private getSettingsTarget(resource: URI): SettingsTarget {
|
||||
if (this.preferencesService.userSettingsResource.toString() === resource.toString()) {
|
||||
return ConfigurationTarget.USER;
|
||||
return ConfigurationTarget.USER_LOCAL;
|
||||
}
|
||||
|
||||
const workspaceSettingsResource = this.preferencesService.workspaceSettingsResource;
|
||||
@@ -955,7 +956,7 @@ class SideBySidePreferencesWidget extends Widget {
|
||||
return folder.uri;
|
||||
}
|
||||
|
||||
return ConfigurationTarget.USER;
|
||||
return ConfigurationTarget.USER_LOCAL;
|
||||
}
|
||||
|
||||
private disposeEditors(): void {
|
||||
@@ -1202,7 +1203,7 @@ class SettingsEditorContribution extends AbstractSettingsEditorContribution impl
|
||||
.then<any>(settingsModel => {
|
||||
if (settingsModel instanceof SettingsEditorModel && this.editor.getModel()) {
|
||||
switch (settingsModel.configurationTarget) {
|
||||
case ConfigurationTarget.USER:
|
||||
case ConfigurationTarget.USER_LOCAL:
|
||||
return this.instantiationService.createInstance(UserSettingsRenderer, this.editor, settingsModel);
|
||||
case ConfigurationTarget.WORKSPACE:
|
||||
return this.instantiationService.createInstance(WorkspaceSettingsRenderer, this.editor, settingsModel);
|
||||
|
||||
@@ -24,11 +24,14 @@ import { ConfigurationTarget } from 'vs/platform/configuration/common/configurat
|
||||
import { IContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IContextMenuService, IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ILabelService } from 'vs/platform/label/common/label';
|
||||
import { REMOTE_HOST_SCHEME } from 'vs/platform/remote/common/remoteHosts';
|
||||
import { activeContrastBorder, badgeBackground, badgeForeground, contrastBorder, focusBorder } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { attachInputBoxStyler, attachStylerCallback } from 'vs/platform/theme/common/styler';
|
||||
import { ICssStyleCollector, ITheme, IThemeService, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
|
||||
import { IWorkspaceContextService, IWorkspaceFolder, WorkbenchState } from 'vs/platform/workspace/common/workspace';
|
||||
import { PANEL_ACTIVE_TITLE_BORDER, PANEL_ACTIVE_TITLE_FOREGROUND, PANEL_INACTIVE_TITLE_FOREGROUND } from 'vs/workbench/common/theme';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
import { ISettingsGroup } from 'vs/workbench/services/preferences/common/preferences';
|
||||
|
||||
export class SettingsHeaderWidget extends Widget implements IViewZone {
|
||||
@@ -464,14 +467,20 @@ export class FolderSettingsActionItem extends BaseActionItem {
|
||||
}
|
||||
}
|
||||
|
||||
export type SettingsTarget = ConfigurationTarget.USER | ConfigurationTarget.WORKSPACE | URI;
|
||||
export type SettingsTarget = ConfigurationTarget.USER_LOCAL | ConfigurationTarget.USER_REMOTE | ConfigurationTarget.WORKSPACE | URI;
|
||||
|
||||
export interface ISettingsTargetsWidgetOptions {
|
||||
enableRemoteSettings?: boolean;
|
||||
}
|
||||
|
||||
export class SettingsTargetsWidget extends Widget {
|
||||
|
||||
private settingsSwitcherBar: ActionBar;
|
||||
private userSettings: Action;
|
||||
private userLocalSettings: Action;
|
||||
private userRemoteSettings: Action;
|
||||
private workspaceSettings: Action;
|
||||
private folderSettings: FolderSettingsActionItem;
|
||||
private options: ISettingsTargetsWidgetOptions;
|
||||
|
||||
private _settingsTarget: SettingsTarget;
|
||||
|
||||
@@ -480,10 +489,14 @@ export class SettingsTargetsWidget extends Widget {
|
||||
|
||||
constructor(
|
||||
parent: HTMLElement,
|
||||
options: ISettingsTargetsWidgetOptions | undefined,
|
||||
@IWorkspaceContextService private readonly contextService: IWorkspaceContextService,
|
||||
@IInstantiationService private readonly instantiationService: IInstantiationService
|
||||
@IInstantiationService private readonly instantiationService: IInstantiationService,
|
||||
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
|
||||
@ILabelService private readonly labelService: ILabelService
|
||||
) {
|
||||
super();
|
||||
this.options = options || {};
|
||||
this.create(parent);
|
||||
this._register(this.contextService.onDidChangeWorkbenchState(() => this.onWorkbenchStateChanged()));
|
||||
this._register(this.contextService.onDidChangeWorkspaceFolders(() => this.update()));
|
||||
@@ -498,18 +511,25 @@ export class SettingsTargetsWidget extends Widget {
|
||||
actionItemProvider: (action: Action) => action.id === 'folderSettings' ? this.folderSettings : undefined
|
||||
}));
|
||||
|
||||
this.userSettings = new Action('userSettings', localize('userSettings', "User Settings"), '.settings-tab', true, () => this.updateTarget(ConfigurationTarget.USER));
|
||||
this.userSettings.tooltip = this.userSettings.label;
|
||||
this.userLocalSettings = new Action('userSettings', localize('userSettings', "User Settings"), '.settings-tab', true, () => this.updateTarget(ConfigurationTarget.USER_LOCAL));
|
||||
this.userLocalSettings.tooltip = this.userLocalSettings.label;
|
||||
|
||||
const remoteAuthority = this.environmentService.configuration.remoteAuthority;
|
||||
const hostLabel = remoteAuthority && this.labelService.getHostLabel(REMOTE_HOST_SCHEME, remoteAuthority);
|
||||
const remoteSettingsLabel = localize('userSettingsRemote', "Remote Settings") +
|
||||
(hostLabel ? ` (${hostLabel})` : '');
|
||||
this.userRemoteSettings = new Action('userSettingsRemote', remoteSettingsLabel, '.settings-tab', true, () => this.updateTarget(ConfigurationTarget.USER_REMOTE));
|
||||
this.userRemoteSettings.tooltip = this.userRemoteSettings.label;
|
||||
|
||||
this.workspaceSettings = new Action('workspaceSettings', localize('workspaceSettings', "Workspace Settings"), '.settings-tab', false, () => this.updateTarget(ConfigurationTarget.WORKSPACE));
|
||||
this.workspaceSettings.tooltip = this.workspaceSettings.label;
|
||||
|
||||
const folderSettingsAction = new Action('folderSettings', localize('folderSettings', "Folder Settings"), '.settings-tab', false, (folder: IWorkspaceFolder) => this.updateTarget(folder ? folder.uri : ConfigurationTarget.USER));
|
||||
const folderSettingsAction = new Action('folderSettings', localize('folderSettings', "Folder Settings"), '.settings-tab', false, (folder: IWorkspaceFolder) => this.updateTarget(folder.uri));
|
||||
this.folderSettings = this.instantiationService.createInstance(FolderSettingsActionItem, folderSettingsAction);
|
||||
|
||||
this.update();
|
||||
|
||||
this.settingsSwitcherBar.push([this.userSettings, this.workspaceSettings, folderSettingsAction]);
|
||||
this.settingsSwitcherBar.push([this.userLocalSettings, this.userRemoteSettings, this.workspaceSettings, folderSettingsAction]);
|
||||
}
|
||||
|
||||
get settingsTarget(): SettingsTarget {
|
||||
@@ -518,7 +538,8 @@ export class SettingsTargetsWidget extends Widget {
|
||||
|
||||
set settingsTarget(settingsTarget: SettingsTarget) {
|
||||
this._settingsTarget = settingsTarget;
|
||||
this.userSettings.checked = ConfigurationTarget.USER === this.settingsTarget;
|
||||
this.userLocalSettings.checked = ConfigurationTarget.USER_LOCAL === this.settingsTarget;
|
||||
this.userRemoteSettings.checked = ConfigurationTarget.USER_REMOTE === this.settingsTarget;
|
||||
this.workspaceSettings.checked = ConfigurationTarget.WORKSPACE === this.settingsTarget;
|
||||
if (this.settingsTarget instanceof URI) {
|
||||
this.folderSettings.getAction().checked = true;
|
||||
@@ -536,13 +557,13 @@ export class SettingsTargetsWidget extends Widget {
|
||||
}
|
||||
|
||||
this.workspaceSettings.label = label;
|
||||
} else if (settingsTarget === ConfigurationTarget.USER) {
|
||||
} else if (settingsTarget === ConfigurationTarget.USER_LOCAL) {
|
||||
let label = localize('userSettings', "User Settings");
|
||||
if (count) {
|
||||
label += ` (${count})`;
|
||||
}
|
||||
|
||||
this.userSettings.label = label;
|
||||
this.userLocalSettings.label = label;
|
||||
} else if (settingsTarget instanceof URI) {
|
||||
this.folderSettings.setCount(settingsTarget, count);
|
||||
}
|
||||
@@ -552,21 +573,27 @@ export class SettingsTargetsWidget extends Widget {
|
||||
this.folderSettings.folder = null;
|
||||
this.update();
|
||||
if (this.settingsTarget === ConfigurationTarget.WORKSPACE && this.contextService.getWorkbenchState() === WorkbenchState.WORKSPACE) {
|
||||
this.updateTarget(ConfigurationTarget.USER);
|
||||
this.updateTarget(ConfigurationTarget.USER_LOCAL);
|
||||
}
|
||||
}
|
||||
|
||||
updateTarget(settingsTarget: SettingsTarget): Promise<void> {
|
||||
const isSameTarget = this.settingsTarget === settingsTarget || settingsTarget instanceof URI && this.settingsTarget instanceof URI && this.settingsTarget.toString() === settingsTarget.toString();
|
||||
const isSameTarget = this.settingsTarget === settingsTarget ||
|
||||
settingsTarget instanceof URI &&
|
||||
this.settingsTarget instanceof URI &&
|
||||
this.settingsTarget.toString() === settingsTarget.toString();
|
||||
|
||||
if (!isSameTarget) {
|
||||
this.settingsTarget = settingsTarget;
|
||||
this._onDidTargetChange.fire(this.settingsTarget);
|
||||
}
|
||||
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
private update(): void {
|
||||
DOM.toggleClass(this.settingsSwitcherBar.domNode, 'empty-workbench', this.contextService.getWorkbenchState() === WorkbenchState.EMPTY);
|
||||
this.userRemoteSettings.enabled = !!(this.options.enableRemoteSettings && this.environmentService.configuration.remoteAuthority);
|
||||
this.workspaceSettings.enabled = this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY;
|
||||
this.folderSettings.getAction().enabled = this.contextService.getWorkbenchState() === WorkbenchState.WORKSPACE && this.contextService.getWorkspace().folders.length > 0;
|
||||
}
|
||||
|
||||
@@ -1174,7 +1174,7 @@ export class SettingsTreeFilter implements ITreeFilter<SettingsTreeElement> {
|
||||
}
|
||||
|
||||
// Non-user scope selected
|
||||
if (element instanceof SettingsTreeSettingElement && this.viewState.settingsTarget !== ConfigurationTarget.USER) {
|
||||
if (element instanceof SettingsTreeSettingElement && this.viewState.settingsTarget !== ConfigurationTarget.USER_LOCAL) {
|
||||
if (!element.matchesScope(this.viewState.settingsTarget)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as arrays from 'vs/base/common/arrays';
|
||||
import { isFalsyOrWhitespace } from 'vs/base/common/strings';
|
||||
import { isArray, withUndefinedAsNull } from 'vs/base/common/types';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { localize } from 'vs/nls';
|
||||
@@ -19,6 +20,7 @@ export const ONLINE_SERVICES_SETTING_TAG = 'usesOnlineServices';
|
||||
export interface ISettingsEditorViewState {
|
||||
settingsTarget: SettingsTarget;
|
||||
tagFilters?: Set<string>;
|
||||
extensionFilters?: Set<string>;
|
||||
filterToCategory?: SettingsTreeGroupElement;
|
||||
}
|
||||
|
||||
@@ -228,6 +230,24 @@ export class SettingsTreeSettingElement extends SettingsTreeElement {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
matchesAnyExtension(extensionFilters?: Set<string>): boolean {
|
||||
if (!extensionFilters || !extensionFilters.size) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!this.setting.extensionInfo) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (let extensionId of extensionFilters) {
|
||||
if (extensionId.toLowerCase() === this.setting.extensionInfo.id.toLowerCase()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export class SettingsTreeModel {
|
||||
@@ -337,9 +357,10 @@ interface IInspectResult {
|
||||
function inspectSetting(key: string, target: SettingsTarget, configurationService: IConfigurationService): IInspectResult {
|
||||
const inspectOverrides = URI.isUri(target) ? { resource: target } : undefined;
|
||||
const inspected = configurationService.inspect(key, inspectOverrides);
|
||||
const targetSelector = target === ConfigurationTarget.USER ? 'user' :
|
||||
target === ConfigurationTarget.WORKSPACE ? 'workspace' :
|
||||
'workspaceFolder';
|
||||
const targetSelector = target === ConfigurationTarget.USER_LOCAL ? 'userLocal' :
|
||||
target === ConfigurationTarget.USER_REMOTE ? 'userRemote' :
|
||||
target === ConfigurationTarget.WORKSPACE ? 'workspace' :
|
||||
'workspaceFolder';
|
||||
const isConfigured = typeof inspected[targetSelector] !== 'undefined';
|
||||
|
||||
return { isConfigured, inspected, targetSelector };
|
||||
@@ -494,7 +515,7 @@ export class SearchResultModel extends SettingsTreeModel {
|
||||
|
||||
// Save time, filter children in the search model instead of relying on the tree filter, which still requires heights to be calculated.
|
||||
this.root.children = this.root.children
|
||||
.filter(child => child instanceof SettingsTreeSettingElement && child.matchesAllTags(this._viewState.tagFilters) && child.matchesScope(this._viewState.settingsTarget));
|
||||
.filter(child => child instanceof SettingsTreeSettingElement && child.matchesAllTags(this._viewState.tagFilters) && child.matchesScope(this._viewState.settingsTarget) && child.matchesAnyExtension(this._viewState.extensionFilters));
|
||||
|
||||
if (this.newExtensionSearchResults && this.newExtensionSearchResults.filterMatches.length) {
|
||||
const newExtElement = new SettingsTreeNewExtensionsElement();
|
||||
@@ -527,11 +548,14 @@ export class SearchResultModel extends SettingsTreeModel {
|
||||
export interface IParsedQuery {
|
||||
tags: string[];
|
||||
query: string;
|
||||
extensionFilters: string[];
|
||||
}
|
||||
|
||||
const tagRegex = /(^|\s)@tag:("([^"]*)"|[^"]\S*)/g;
|
||||
const extensionRegex = /(^|\s)@ext:("([^"]*)"|[^"]\S*)?/g;
|
||||
export function parseQuery(query: string): IParsedQuery {
|
||||
const tags: string[] = [];
|
||||
let extensions: string[] = [];
|
||||
query = query.replace(tagRegex, (_, __, quotedTag, tag) => {
|
||||
tags.push(tag || quotedTag);
|
||||
return '';
|
||||
@@ -542,10 +566,19 @@ export function parseQuery(query: string): IParsedQuery {
|
||||
return '';
|
||||
});
|
||||
|
||||
query = query.replace(extensionRegex, (_, __, quotedExtensionId, extensionId) => {
|
||||
let extensionIdQuery: string = extensionId || quotedExtensionId;
|
||||
if (extensionIdQuery) {
|
||||
extensions.push(...extensionIdQuery.split(',').map(s => s.trim()).filter(s => !isFalsyOrWhitespace(s)));
|
||||
}
|
||||
return '';
|
||||
});
|
||||
|
||||
query = query.trim();
|
||||
|
||||
return {
|
||||
tags,
|
||||
extensionFilters: extensions,
|
||||
query
|
||||
};
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ export class TOCTreeModel {
|
||||
}
|
||||
|
||||
// Check everything that the SettingsFilter checks except whether it's filtered by a category
|
||||
return child.matchesScope(this._viewState.settingsTarget) && child.matchesAllTags(this._viewState.tagFilters);
|
||||
return child.matchesScope(this._viewState.settingsTarget) && child.matchesAllTags(this._viewState.tagFilters) && child.matchesAnyExtension(this._viewState.extensionFilters);
|
||||
}).length;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,5 +108,6 @@ export const KEYBINDINGS_EDITOR_SHOW_USER_KEYBINDINGS = 'keybindings.editor.show
|
||||
export const DEFAULT_SETTINGS_EDITOR_SETTING = 'workbench.settings.openDefaultSettings';
|
||||
|
||||
export const MODIFIED_SETTING_TAG = 'modified';
|
||||
export const EXTENSION_SETTING_TAG = 'ext:';
|
||||
|
||||
export const SETTINGS_COMMAND_OPEN_SETTINGS = 'workbench.action.openSettings';
|
||||
|
||||
@@ -217,8 +217,8 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
|
||||
weight: KeybindingWeight.WorkbenchContrib,
|
||||
when: null,
|
||||
primary: KeyMod.CtrlCmd | KeyCode.US_COMMA,
|
||||
handler: (accessor, args: any) => {
|
||||
accessor.get(IPreferencesService).openSettings();
|
||||
handler: (accessor, args: string | undefined) => {
|
||||
accessor.get(IPreferencesService).openSettings(undefined, typeof args === 'string' ? args : undefined);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cance
|
||||
import * as collections from 'vs/base/common/collections';
|
||||
import { getErrorMessage, isPromiseCanceledError } from 'vs/base/common/errors';
|
||||
import { Iterator } from 'vs/base/common/iterator';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import { isArray, withNullAsUndefined } from 'vs/base/common/types';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import 'vs/css!./media/settingsEditor2';
|
||||
@@ -35,7 +36,7 @@ import { AbstractSettingRenderer, ISettingLinkClickEvent, ISettingOverrideClickE
|
||||
import { ISettingsEditorViewState, parseQuery, SearchResultIdx, SearchResultModel, SettingsTreeElement, SettingsTreeGroupChild, SettingsTreeGroupElement, SettingsTreeModel, SettingsTreeSettingElement } from 'vs/workbench/contrib/preferences/browser/settingsTreeModels';
|
||||
import { settingsTextInputBorder } from 'vs/workbench/contrib/preferences/browser/settingsWidgets';
|
||||
import { createTOCIterator, TOCTree, TOCTreeModel } from 'vs/workbench/contrib/preferences/browser/tocTree';
|
||||
import { CONTEXT_SETTINGS_EDITOR, CONTEXT_SETTINGS_SEARCH_FOCUS, CONTEXT_TOC_ROW_FOCUS, IPreferencesSearchService, ISearchProvider, MODIFIED_SETTING_TAG, SETTINGS_EDITOR_COMMAND_SHOW_CONTEXT_MENU } from 'vs/workbench/contrib/preferences/common/preferences';
|
||||
import { CONTEXT_SETTINGS_EDITOR, CONTEXT_SETTINGS_SEARCH_FOCUS, CONTEXT_TOC_ROW_FOCUS, IPreferencesSearchService, ISearchProvider, MODIFIED_SETTING_TAG, EXTENSION_SETTING_TAG, SETTINGS_EDITOR_COMMAND_SHOW_CONTEXT_MENU } from 'vs/workbench/contrib/preferences/common/preferences';
|
||||
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { IPreferencesService, ISearchResult, ISettingsEditorModel, ISettingsEditorOptions, SettingsEditorOptions, SettingValueType } from 'vs/workbench/services/preferences/common/preferences';
|
||||
import { SettingsEditor2Input } from 'vs/workbench/services/preferences/common/preferencesEditorInput';
|
||||
@@ -69,7 +70,7 @@ export class SettingsEditor2 extends BaseEditor {
|
||||
private static SETTING_UPDATE_SLOW_DEBOUNCE: number = 1000;
|
||||
|
||||
private static readonly SUGGESTIONS: string[] = [
|
||||
`@${MODIFIED_SETTING_TAG}`, '@tag:usesOnlineServices'
|
||||
`@${MODIFIED_SETTING_TAG}`, '@tag:usesOnlineServices', `@${EXTENSION_SETTING_TAG}`
|
||||
];
|
||||
|
||||
private static shouldSettingUpdateFast(type: SettingValueType | SettingValueType[]): boolean {
|
||||
@@ -149,7 +150,7 @@ export class SettingsEditor2 extends BaseEditor {
|
||||
this.delayedFilterLogging = new Delayer<void>(1000);
|
||||
this.localSearchDelayer = new Delayer(300);
|
||||
this.remoteSearchThrottle = new ThrottledDelayer(200);
|
||||
this.viewState = { settingsTarget: ConfigurationTarget.USER };
|
||||
this.viewState = { settingsTarget: ConfigurationTarget.USER_LOCAL };
|
||||
|
||||
this.settingFastUpdateDelayer = new Delayer<void>(SettingsEditor2.SETTING_UPDATE_FAST_DEBOUNCE);
|
||||
this.settingSlowUpdateDelayer = new Delayer<void>(SettingsEditor2.SETTING_UPDATE_SLOW_DEBOUNCE);
|
||||
@@ -212,10 +213,10 @@ export class SettingsEditor2 extends BaseEditor {
|
||||
if (!options) {
|
||||
if (!this.viewState.settingsTarget) {
|
||||
// Persist?
|
||||
options = SettingsEditorOptions.create({ target: ConfigurationTarget.USER });
|
||||
options = SettingsEditorOptions.create({ target: ConfigurationTarget.USER_LOCAL });
|
||||
}
|
||||
} else if (!options.target) {
|
||||
options.target = ConfigurationTarget.USER;
|
||||
options.target = ConfigurationTarget.USER_LOCAL;
|
||||
}
|
||||
this._setOptions(options);
|
||||
|
||||
@@ -371,7 +372,7 @@ export class SettingsEditor2 extends BaseEditor {
|
||||
this.searchWidget = this._register(this.instantiationService.createInstance(SuggestEnabledInput, `${SettingsEditor2.ID}.searchbox`, searchContainer, {
|
||||
triggerCharacters: ['@'],
|
||||
provideResults: (query: string) => {
|
||||
return SettingsEditor2.SUGGESTIONS.filter(tag => query.indexOf(tag) === -1).map(tag => tag + ' ');
|
||||
return SettingsEditor2.SUGGESTIONS.filter(tag => query.indexOf(tag) === -1).map(tag => strings.endsWith(tag, ':') ? tag : tag + ' ');
|
||||
}
|
||||
}, searchBoxLabel, 'settingseditor:searchinput' + SettingsEditor2.NUM_INSTANCES++, {
|
||||
placeholderText: searchBoxLabel,
|
||||
@@ -406,8 +407,8 @@ export class SettingsEditor2 extends BaseEditor {
|
||||
|
||||
const headerControlsContainer = DOM.append(this.headerContainer, $('.settings-header-controls'));
|
||||
const targetWidgetContainer = DOM.append(headerControlsContainer, $('.settings-target-container'));
|
||||
this.settingsTargetsWidget = this._register(this.instantiationService.createInstance(SettingsTargetsWidget, targetWidgetContainer));
|
||||
this.settingsTargetsWidget.settingsTarget = ConfigurationTarget.USER;
|
||||
this.settingsTargetsWidget = this._register(this.instantiationService.createInstance(SettingsTargetsWidget, targetWidgetContainer, { enableRemoteSettings: true }));
|
||||
this.settingsTargetsWidget.settingsTarget = ConfigurationTarget.USER_LOCAL;
|
||||
this.settingsTargetsWidget.onDidTargetChange(target => this.onDidSettingsTargetChange(target));
|
||||
}
|
||||
|
||||
@@ -458,8 +459,10 @@ export class SettingsEditor2 extends BaseEditor {
|
||||
const currentSettingsTarget = this.settingsTargetsWidget.settingsTarget;
|
||||
|
||||
const options: ISettingsEditorOptions = { query };
|
||||
if (currentSettingsTarget === ConfigurationTarget.USER) {
|
||||
if (currentSettingsTarget === ConfigurationTarget.USER_LOCAL) {
|
||||
return this.preferencesService.openGlobalSettings(true, options);
|
||||
} else if (currentSettingsTarget === ConfigurationTarget.USER_REMOTE) {
|
||||
return this.preferencesService.openRemoteSettings();
|
||||
} else if (currentSettingsTarget === ConfigurationTarget.WORKSPACE) {
|
||||
return this.preferencesService.openWorkspaceSettings(true, options);
|
||||
} else {
|
||||
@@ -615,8 +618,10 @@ export class SettingsEditor2 extends BaseEditor {
|
||||
this._register(this.settingRenderers.onDidClickOverrideElement((element: ISettingOverrideClickEvent) => {
|
||||
if (ConfigurationTargetToString(ConfigurationTarget.WORKSPACE) === element.scope.toUpperCase()) {
|
||||
this.settingsTargetsWidget.updateTarget(ConfigurationTarget.WORKSPACE);
|
||||
} else if (ConfigurationTargetToString(ConfigurationTarget.USER) === element.scope.toUpperCase()) {
|
||||
this.settingsTargetsWidget.updateTarget(ConfigurationTarget.USER);
|
||||
} else if (ConfigurationTargetToString(ConfigurationTarget.USER_LOCAL) === element.scope.toUpperCase()) {
|
||||
this.settingsTargetsWidget.updateTarget(ConfigurationTarget.USER_LOCAL);
|
||||
} else if (ConfigurationTargetToString(ConfigurationTarget.USER_REMOTE) === element.scope.toUpperCase()) {
|
||||
this.settingsTargetsWidget.updateTarget(ConfigurationTarget.USER_REMOTE);
|
||||
}
|
||||
|
||||
this.searchWidget.setValue(element.targetKey);
|
||||
@@ -792,9 +797,10 @@ export class SettingsEditor2 extends BaseEditor {
|
||||
}
|
||||
}
|
||||
|
||||
const reportedTarget = props.settingsTarget === ConfigurationTarget.USER ? 'user' :
|
||||
props.settingsTarget === ConfigurationTarget.WORKSPACE ? 'workspace' :
|
||||
'folder';
|
||||
const reportedTarget = props.settingsTarget === ConfigurationTarget.USER_LOCAL ? 'user' :
|
||||
props.settingsTarget === ConfigurationTarget.USER_REMOTE ? 'user_remote' :
|
||||
props.settingsTarget === ConfigurationTarget.WORKSPACE ? 'workspace' :
|
||||
'folder';
|
||||
|
||||
const data = {
|
||||
key: props.key,
|
||||
@@ -1035,17 +1041,19 @@ export class SettingsEditor2 extends BaseEditor {
|
||||
|
||||
private triggerSearch(query: string): Promise<void> {
|
||||
this.viewState.tagFilters = new Set<string>();
|
||||
this.viewState.extensionFilters = new Set<string>();
|
||||
if (query) {
|
||||
const parsedQuery = parseQuery(query);
|
||||
query = parsedQuery.query;
|
||||
parsedQuery.tags.forEach(tag => this.viewState.tagFilters!.add(tag));
|
||||
parsedQuery.extensionFilters.forEach(extensionId => this.viewState.extensionFilters!.add(extensionId));
|
||||
}
|
||||
|
||||
if (query && query !== '@') {
|
||||
query = this.parseSettingFromJSON(query) || query;
|
||||
return this.triggerFilterPreferences(query);
|
||||
} else {
|
||||
if (this.viewState.tagFilters && this.viewState.tagFilters.size) {
|
||||
if ((this.viewState.tagFilters && this.viewState.tagFilters.size) || (this.viewState.extensionFilters && this.viewState.extensionFilters.size)) {
|
||||
this.searchResultModel = this.createFilterModel();
|
||||
} else {
|
||||
this.searchResultModel = null;
|
||||
|
||||
@@ -116,6 +116,7 @@ suite('SettingsTree', () => {
|
||||
'',
|
||||
<IParsedQuery>{
|
||||
tags: [],
|
||||
extensionFilters: [],
|
||||
query: ''
|
||||
});
|
||||
|
||||
@@ -123,6 +124,7 @@ suite('SettingsTree', () => {
|
||||
'@modified',
|
||||
<IParsedQuery>{
|
||||
tags: ['modified'],
|
||||
extensionFilters: [],
|
||||
query: ''
|
||||
});
|
||||
|
||||
@@ -130,6 +132,7 @@ suite('SettingsTree', () => {
|
||||
'@tag:foo',
|
||||
<IParsedQuery>{
|
||||
tags: ['foo'],
|
||||
extensionFilters: [],
|
||||
query: ''
|
||||
});
|
||||
|
||||
@@ -137,6 +140,7 @@ suite('SettingsTree', () => {
|
||||
'@modified foo',
|
||||
<IParsedQuery>{
|
||||
tags: ['modified'],
|
||||
extensionFilters: [],
|
||||
query: 'foo'
|
||||
});
|
||||
|
||||
@@ -144,6 +148,7 @@ suite('SettingsTree', () => {
|
||||
'@tag:foo @modified',
|
||||
<IParsedQuery>{
|
||||
tags: ['foo', 'modified'],
|
||||
extensionFilters: [],
|
||||
query: ''
|
||||
});
|
||||
|
||||
@@ -151,6 +156,7 @@ suite('SettingsTree', () => {
|
||||
'@tag:foo @modified my query',
|
||||
<IParsedQuery>{
|
||||
tags: ['foo', 'modified'],
|
||||
extensionFilters: [],
|
||||
query: 'my query'
|
||||
});
|
||||
|
||||
@@ -158,6 +164,7 @@ suite('SettingsTree', () => {
|
||||
'test @modified query',
|
||||
<IParsedQuery>{
|
||||
tags: ['modified'],
|
||||
extensionFilters: [],
|
||||
query: 'test query'
|
||||
});
|
||||
|
||||
@@ -165,6 +172,7 @@ suite('SettingsTree', () => {
|
||||
'test @modified',
|
||||
<IParsedQuery>{
|
||||
tags: ['modified'],
|
||||
extensionFilters: [],
|
||||
query: 'test'
|
||||
});
|
||||
|
||||
@@ -172,7 +180,24 @@ suite('SettingsTree', () => {
|
||||
'query has @ for some reason',
|
||||
<IParsedQuery>{
|
||||
tags: [],
|
||||
extensionFilters: [],
|
||||
query: 'query has @ for some reason'
|
||||
});
|
||||
|
||||
testParseQuery(
|
||||
'@ext:github.vscode-pull-request-github',
|
||||
<IParsedQuery>{
|
||||
tags: [],
|
||||
extensionFilters: ['github.vscode-pull-request-github'],
|
||||
query: ''
|
||||
});
|
||||
|
||||
testParseQuery(
|
||||
'@ext:github.vscode-pull-request-github,vscode.git',
|
||||
<IParsedQuery>{
|
||||
tags: [],
|
||||
extensionFilters: ['github.vscode-pull-request-github', 'vscode.git'],
|
||||
query: ''
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user