mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-31 09:10:30 -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user