mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-31 09:10:30 -04:00
Merge from vscode 718331d6f3ebd1b571530ab499edb266ddd493d5
This commit is contained in:
@@ -373,7 +373,7 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
|
||||
|
||||
const actionBar = this._register(new ActionBar(this.actionsContainer, {
|
||||
animated: false,
|
||||
actionViewItemProvider: (action: Action) => {
|
||||
actionViewItemProvider: (action: IAction) => {
|
||||
if (action.id === this.sortByPrecedenceAction.id) {
|
||||
return new CheckboxActionViewItem(null, action);
|
||||
}
|
||||
@@ -461,7 +461,7 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
|
||||
overrideStyles: {
|
||||
listBackground: editorBackground
|
||||
}
|
||||
}));
|
||||
})) as WorkbenchList<IListEntry>;
|
||||
this._register(this.keybindingsList.onContextMenu(e => this.onContextMenu(e)));
|
||||
this._register(this.keybindingsList.onFocusChange(e => this.onFocusChange(e)));
|
||||
this._register(this.keybindingsList.onDidFocus(() => {
|
||||
|
||||
@@ -31,12 +31,12 @@ import { KeybindingParser } from 'vs/base/common/keybindingParser';
|
||||
import { EditorOption } from 'vs/editor/common/config/editorOptions';
|
||||
import { equals } from 'vs/base/common/arrays';
|
||||
import { assertIsDefined } from 'vs/base/common/types';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { isEqual } from 'vs/base/common/resources';
|
||||
|
||||
const NLS_LAUNCH_MESSAGE = nls.localize('defineKeybinding.start', "Define Keybinding");
|
||||
const NLS_KB_LAYOUT_ERROR_MESSAGE = nls.localize('defineKeybinding.kbLayoutErrorMessage', "You won't be able to produce this key combination under your current keyboard layout.");
|
||||
|
||||
const INTERESTING_FILE = /keybindings\.json$/;
|
||||
|
||||
export class DefineKeybindingController extends Disposable implements IEditorContribution {
|
||||
|
||||
public static readonly ID = 'editor.contrib.defineKeybinding';
|
||||
@@ -50,7 +50,8 @@ export class DefineKeybindingController extends Disposable implements IEditorCon
|
||||
|
||||
constructor(
|
||||
private _editor: ICodeEditor,
|
||||
@IInstantiationService private readonly _instantiationService: IInstantiationService
|
||||
@IInstantiationService private readonly _instantiationService: IInstantiationService,
|
||||
@IEnvironmentService private readonly _environmentService: IEnvironmentService
|
||||
) {
|
||||
super();
|
||||
|
||||
@@ -69,7 +70,7 @@ export class DefineKeybindingController extends Disposable implements IEditorCon
|
||||
}
|
||||
|
||||
private _update(): void {
|
||||
if (!isInterestingEditorModel(this._editor)) {
|
||||
if (!isInterestingEditorModel(this._editor, this._environmentService)) {
|
||||
this._disposeKeybindingWidgetRenderer();
|
||||
this._disposeKeybindingDecorationRenderer();
|
||||
return;
|
||||
@@ -363,7 +364,7 @@ class DefineKeybindingCommand extends EditorCommand {
|
||||
}
|
||||
|
||||
runEditorCommand(accessor: ServicesAccessor, editor: ICodeEditor): void {
|
||||
if (!isInterestingEditorModel(editor) || editor.getOption(EditorOption.readOnly)) {
|
||||
if (!isInterestingEditorModel(editor, accessor.get(IEnvironmentService)) || editor.getOption(EditorOption.readOnly)) {
|
||||
return;
|
||||
}
|
||||
const controller = DefineKeybindingController.get(editor);
|
||||
@@ -373,13 +374,12 @@ class DefineKeybindingCommand extends EditorCommand {
|
||||
}
|
||||
}
|
||||
|
||||
function isInterestingEditorModel(editor: ICodeEditor): boolean {
|
||||
function isInterestingEditorModel(editor: ICodeEditor, environmentService: IEnvironmentService): boolean {
|
||||
const model = editor.getModel();
|
||||
if (!model) {
|
||||
return false;
|
||||
}
|
||||
const url = model.uri.toString();
|
||||
return INTERESTING_FILE.test(url);
|
||||
return isEqual(model.uri, environmentService.keybindingsResource);
|
||||
}
|
||||
|
||||
registerEditorContribution(DefineKeybindingController.ID, DefineKeybindingController);
|
||||
|
||||
@@ -7,38 +7,37 @@ import { KeyChord, KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import 'vs/css!../browser/media/preferences';
|
||||
import { Command } from 'vs/editor/browser/editorExtensions';
|
||||
import { Context as SuggestContext } from 'vs/editor/contrib/suggest/suggest';
|
||||
import * as nls from 'vs/nls';
|
||||
import { MenuId, MenuRegistry, SyncActionDescriptor } from 'vs/platform/actions/common/actions';
|
||||
import { Action2, MenuId, MenuRegistry, registerAction2, SyncActionDescriptor } from 'vs/platform/actions/common/actions';
|
||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { WorkbenchStateContext, IsMacNativeContext, RemoteNameContext } from 'vs/workbench/browser/contextkeys';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { ILabelService } from 'vs/platform/label/common/label';
|
||||
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { REMOTE_HOST_SCHEME } from 'vs/platform/remote/common/remoteHosts';
|
||||
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
|
||||
import { IsMacNativeContext, RemoteNameContext, WorkbenchStateContext } from 'vs/workbench/browser/contextkeys';
|
||||
import { EditorDescriptor, Extensions as EditorExtensions, IEditorRegistry } from 'vs/workbench/browser/editor';
|
||||
import { Extensions, IWorkbenchActionRegistry } from 'vs/workbench/common/actions';
|
||||
import { Extensions as WorkbenchExtensions, IWorkbenchContribution, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions';
|
||||
import { EditorInput, Extensions as EditorInputExtensions, IEditorInputFactory, IEditorInputFactoryRegistry } from 'vs/workbench/common/editor';
|
||||
import { ResourceContextKey } from 'vs/workbench/common/resources';
|
||||
import { ExplorerFolderContext, ExplorerRootContext } from 'vs/workbench/contrib/files/common/files';
|
||||
import { KeybindingsEditor } from 'vs/workbench/contrib/preferences/browser/keybindingsEditor';
|
||||
import { ConfigureLanguageBasedSettingsAction, OpenDefaultKeybindingsFileAction, OpenFolderSettingsAction, OpenGlobalKeybindingsAction, OpenGlobalKeybindingsFileAction, OpenGlobalSettingsAction, OpenRawDefaultSettingsAction, OpenSettings2Action, OpenSettingsJsonAction, OpenWorkspaceSettingsAction, OPEN_FOLDER_SETTINGS_COMMAND, OPEN_FOLDER_SETTINGS_LABEL, OpenRemoteSettingsAction } from 'vs/workbench/contrib/preferences/browser/preferencesActions';
|
||||
import { ConfigureLanguageBasedSettingsAction, OpenDefaultKeybindingsFileAction, OpenFolderSettingsAction, OpenGlobalKeybindingsAction, OpenGlobalKeybindingsFileAction, OpenGlobalSettingsAction, OpenRawDefaultSettingsAction, OpenRemoteSettingsAction, OpenSettings2Action, OpenSettingsJsonAction, OpenWorkspaceSettingsAction, OPEN_FOLDER_SETTINGS_COMMAND, OPEN_FOLDER_SETTINGS_LABEL } from 'vs/workbench/contrib/preferences/browser/preferencesActions';
|
||||
import { PreferencesEditor } from 'vs/workbench/contrib/preferences/browser/preferencesEditor';
|
||||
import { CONTEXT_KEYBINDINGS_EDITOR, CONTEXT_KEYBINDINGS_SEARCH_FOCUS, CONTEXT_KEYBINDING_FOCUS, CONTEXT_SETTINGS_EDITOR, CONTEXT_SETTINGS_JSON_EDITOR, CONTEXT_SETTINGS_SEARCH_FOCUS, CONTEXT_TOC_ROW_FOCUS, IKeybindingsEditor, KEYBINDINGS_EDITOR_COMMAND_CLEAR_SEARCH_RESULTS, KEYBINDINGS_EDITOR_COMMAND_COPY, KEYBINDINGS_EDITOR_COMMAND_COPY_COMMAND, KEYBINDINGS_EDITOR_COMMAND_DEFINE, KEYBINDINGS_EDITOR_COMMAND_FOCUS_KEYBINDINGS, KEYBINDINGS_EDITOR_COMMAND_RECORD_SEARCH_KEYS, KEYBINDINGS_EDITOR_COMMAND_REMOVE, KEYBINDINGS_EDITOR_COMMAND_RESET, KEYBINDINGS_EDITOR_COMMAND_SEARCH, KEYBINDINGS_EDITOR_COMMAND_SHOW_SIMILAR, KEYBINDINGS_EDITOR_COMMAND_SORTBY_PRECEDENCE, KEYBINDINGS_EDITOR_SHOW_DEFAULT_KEYBINDINGS, KEYBINDINGS_EDITOR_SHOW_USER_KEYBINDINGS, MODIFIED_SETTING_TAG, SETTINGS_EDITOR_COMMAND_CLEAR_SEARCH_RESULTS, SETTINGS_EDITOR_COMMAND_EDIT_FOCUSED_SETTING, SETTINGS_EDITOR_COMMAND_FILTER_MODIFIED, SETTINGS_EDITOR_COMMAND_FILTER_ONLINE, SETTINGS_EDITOR_COMMAND_FOCUS_FILE, SETTINGS_EDITOR_COMMAND_FOCUS_NEXT_SETTING, SETTINGS_EDITOR_COMMAND_FOCUS_PREVIOUS_SETTING, SETTINGS_EDITOR_COMMAND_FOCUS_SETTINGS_FROM_SEARCH, SETTINGS_EDITOR_COMMAND_FOCUS_SETTINGS_LIST, SETTINGS_EDITOR_COMMAND_SEARCH, SETTINGS_EDITOR_COMMAND_SHOW_CONTEXT_MENU, SETTINGS_EDITOR_COMMAND_SWITCH_TO_JSON, SETTINGS_COMMAND_OPEN_SETTINGS, KEYBINDINGS_EDITOR_COMMAND_DEFINE_WHEN } from 'vs/workbench/contrib/preferences/common/preferences';
|
||||
import { PreferencesContribution } from 'vs/workbench/contrib/preferences/common/preferencesContribution';
|
||||
import { SettingsEditor2 } from 'vs/workbench/contrib/preferences/browser/settingsEditor2';
|
||||
import { CONTEXT_KEYBINDINGS_EDITOR, CONTEXT_KEYBINDINGS_SEARCH_FOCUS, CONTEXT_KEYBINDING_FOCUS, CONTEXT_SETTINGS_EDITOR, CONTEXT_SETTINGS_JSON_EDITOR, CONTEXT_SETTINGS_SEARCH_FOCUS, CONTEXT_TOC_ROW_FOCUS, IKeybindingsEditor, KEYBINDINGS_EDITOR_COMMAND_CLEAR_SEARCH_RESULTS, KEYBINDINGS_EDITOR_COMMAND_COPY, KEYBINDINGS_EDITOR_COMMAND_COPY_COMMAND, KEYBINDINGS_EDITOR_COMMAND_DEFINE, KEYBINDINGS_EDITOR_COMMAND_DEFINE_WHEN, KEYBINDINGS_EDITOR_COMMAND_FOCUS_KEYBINDINGS, KEYBINDINGS_EDITOR_COMMAND_RECORD_SEARCH_KEYS, KEYBINDINGS_EDITOR_COMMAND_REMOVE, KEYBINDINGS_EDITOR_COMMAND_RESET, KEYBINDINGS_EDITOR_COMMAND_SEARCH, KEYBINDINGS_EDITOR_COMMAND_SHOW_SIMILAR, KEYBINDINGS_EDITOR_COMMAND_SORTBY_PRECEDENCE, KEYBINDINGS_EDITOR_SHOW_DEFAULT_KEYBINDINGS, KEYBINDINGS_EDITOR_SHOW_USER_KEYBINDINGS, MODIFIED_SETTING_TAG, SETTINGS_COMMAND_OPEN_SETTINGS, SETTINGS_EDITOR_COMMAND_CLEAR_SEARCH_RESULTS, SETTINGS_EDITOR_COMMAND_EDIT_FOCUSED_SETTING, SETTINGS_EDITOR_COMMAND_FILTER_MODIFIED, SETTINGS_EDITOR_COMMAND_FILTER_ONLINE, SETTINGS_EDITOR_COMMAND_FOCUS_FILE, SETTINGS_EDITOR_COMMAND_FOCUS_NEXT_SETTING, SETTINGS_EDITOR_COMMAND_FOCUS_PREVIOUS_SETTING, SETTINGS_EDITOR_COMMAND_FOCUS_SETTINGS_FROM_SEARCH, SETTINGS_EDITOR_COMMAND_FOCUS_SETTINGS_LIST, SETTINGS_EDITOR_COMMAND_SEARCH, SETTINGS_EDITOR_COMMAND_SHOW_CONTEXT_MENU, SETTINGS_EDITOR_COMMAND_SWITCH_TO_JSON } from 'vs/workbench/contrib/preferences/common/preferences';
|
||||
import { PreferencesContribution } from 'vs/workbench/contrib/preferences/common/preferencesContribution';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences';
|
||||
import { DefaultPreferencesEditorInput, KeybindingsEditorInput, PreferencesEditorInput, SettingsEditor2Input } from 'vs/workbench/services/preferences/common/preferencesEditorInput';
|
||||
import { ExplorerRootContext, ExplorerFolderContext } from 'vs/workbench/contrib/files/common/files';
|
||||
import { ILabelService } from 'vs/platform/label/common/label';
|
||||
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { REMOTE_HOST_SCHEME } from 'vs/platform/remote/common/remoteHosts';
|
||||
|
||||
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
|
||||
EditorDescriptor.create(
|
||||
@@ -576,155 +575,216 @@ MenuRegistry.appendMenuItem(MenuId.EditorTitle, {
|
||||
group: '1_keyboard_preferences_actions'
|
||||
});
|
||||
|
||||
abstract class SettingsCommand extends Command {
|
||||
|
||||
protected getPreferencesEditor(accessor: ServicesAccessor): PreferencesEditor | SettingsEditor2 | null {
|
||||
const activeControl = accessor.get(IEditorService).activeControl;
|
||||
if (activeControl instanceof PreferencesEditor || activeControl instanceof SettingsEditor2) {
|
||||
return activeControl;
|
||||
}
|
||||
|
||||
return null;
|
||||
function getPreferencesEditor(accessor: ServicesAccessor): PreferencesEditor | SettingsEditor2 | null {
|
||||
const activeControl = accessor.get(IEditorService).activeControl;
|
||||
if (activeControl instanceof PreferencesEditor || activeControl instanceof SettingsEditor2) {
|
||||
return activeControl;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
class StartSearchDefaultSettingsCommand extends SettingsCommand {
|
||||
|
||||
runCommand(accessor: ServicesAccessor, args: any): void {
|
||||
const preferencesEditor = this.getPreferencesEditor(accessor);
|
||||
registerAction2(class extends Action2 {
|
||||
constructor() {
|
||||
super({
|
||||
id: SETTINGS_EDITOR_COMMAND_SEARCH,
|
||||
precondition: ContextKeyExpr.and(CONTEXT_SETTINGS_EDITOR),
|
||||
keybinding: {
|
||||
primary: KeyMod.CtrlCmd | KeyCode.KEY_F,
|
||||
weight: KeybindingWeight.EditorContrib,
|
||||
when: null
|
||||
},
|
||||
title: nls.localize('settings.focusSearch', "Focus settings search")
|
||||
});
|
||||
}
|
||||
|
||||
run(accessor: ServicesAccessor) {
|
||||
const preferencesEditor = getPreferencesEditor(accessor);
|
||||
if (preferencesEditor) {
|
||||
preferencesEditor.focusSearch();
|
||||
}
|
||||
}
|
||||
}
|
||||
const startSearchCommand = new StartSearchDefaultSettingsCommand({
|
||||
id: SETTINGS_EDITOR_COMMAND_SEARCH,
|
||||
precondition: ContextKeyExpr.and(CONTEXT_SETTINGS_EDITOR),
|
||||
kbOpts: { primary: KeyMod.CtrlCmd | KeyCode.KEY_F, weight: KeybindingWeight.EditorContrib }
|
||||
});
|
||||
startSearchCommand.register();
|
||||
|
||||
class ClearSearchResultsCommand extends SettingsCommand {
|
||||
registerAction2(class extends Action2 {
|
||||
constructor() {
|
||||
super({
|
||||
id: SETTINGS_EDITOR_COMMAND_CLEAR_SEARCH_RESULTS,
|
||||
precondition: CONTEXT_SETTINGS_SEARCH_FOCUS,
|
||||
keybinding: {
|
||||
primary: KeyCode.Escape,
|
||||
weight: KeybindingWeight.EditorContrib,
|
||||
when: null
|
||||
},
|
||||
title: nls.localize('settings.clearResults', "Clear settings search results")
|
||||
});
|
||||
}
|
||||
|
||||
runCommand(accessor: ServicesAccessor, args: any): void {
|
||||
const preferencesEditor = this.getPreferencesEditor(accessor);
|
||||
run(accessor: ServicesAccessor) {
|
||||
const preferencesEditor = getPreferencesEditor(accessor);
|
||||
if (preferencesEditor) {
|
||||
preferencesEditor.clearSearchResults();
|
||||
}
|
||||
}
|
||||
}
|
||||
const clearSearchResultsCommand = new ClearSearchResultsCommand({
|
||||
id: SETTINGS_EDITOR_COMMAND_CLEAR_SEARCH_RESULTS,
|
||||
precondition: CONTEXT_SETTINGS_SEARCH_FOCUS,
|
||||
kbOpts: { primary: KeyCode.Escape, weight: KeybindingWeight.EditorContrib }
|
||||
});
|
||||
clearSearchResultsCommand.register();
|
||||
|
||||
class FocusSettingsFileEditorCommand extends SettingsCommand {
|
||||
registerAction2(class extends Action2 {
|
||||
constructor() {
|
||||
super({
|
||||
id: SETTINGS_EDITOR_COMMAND_FOCUS_FILE,
|
||||
precondition: ContextKeyExpr.and(CONTEXT_SETTINGS_SEARCH_FOCUS, SuggestContext.Visible.toNegated()),
|
||||
keybinding: {
|
||||
primary: KeyCode.DownArrow,
|
||||
weight: KeybindingWeight.EditorContrib,
|
||||
when: null
|
||||
},
|
||||
title: nls.localize('settings.focusFile', "Focus settings file")
|
||||
});
|
||||
}
|
||||
|
||||
runCommand(accessor: ServicesAccessor, args: any): void {
|
||||
const preferencesEditor = this.getPreferencesEditor(accessor);
|
||||
run(accessor: ServicesAccessor, args: any): void {
|
||||
const preferencesEditor = getPreferencesEditor(accessor);
|
||||
if (preferencesEditor instanceof PreferencesEditor) {
|
||||
preferencesEditor.focusSettingsFileEditor();
|
||||
} else if (preferencesEditor) {
|
||||
preferencesEditor.focusSettings();
|
||||
}
|
||||
}
|
||||
}
|
||||
const focusSettingsFileEditorCommand = new FocusSettingsFileEditorCommand({
|
||||
id: SETTINGS_EDITOR_COMMAND_FOCUS_FILE,
|
||||
precondition: ContextKeyExpr.and(CONTEXT_SETTINGS_SEARCH_FOCUS, SuggestContext.Visible.toNegated()),
|
||||
kbOpts: { primary: KeyCode.DownArrow, weight: KeybindingWeight.EditorContrib }
|
||||
});
|
||||
focusSettingsFileEditorCommand.register();
|
||||
|
||||
const focusSettingsFromSearchCommand = new FocusSettingsFileEditorCommand({
|
||||
id: SETTINGS_EDITOR_COMMAND_FOCUS_SETTINGS_FROM_SEARCH,
|
||||
precondition: ContextKeyExpr.and(CONTEXT_SETTINGS_SEARCH_FOCUS, SuggestContext.Visible.toNegated()),
|
||||
kbOpts: { primary: KeyCode.DownArrow, weight: KeybindingWeight.WorkbenchContrib }
|
||||
registerAction2(class extends Action2 {
|
||||
constructor() {
|
||||
super({
|
||||
id: SETTINGS_EDITOR_COMMAND_FOCUS_SETTINGS_FROM_SEARCH,
|
||||
precondition: ContextKeyExpr.and(CONTEXT_SETTINGS_SEARCH_FOCUS, SuggestContext.Visible.toNegated()),
|
||||
keybinding: {
|
||||
primary: KeyCode.DownArrow,
|
||||
weight: KeybindingWeight.WorkbenchContrib,
|
||||
when: null
|
||||
},
|
||||
title: nls.localize('settings.focusFile', "Focus settings file")
|
||||
});
|
||||
}
|
||||
|
||||
run(accessor: ServicesAccessor, args: any): void {
|
||||
const preferencesEditor = getPreferencesEditor(accessor);
|
||||
if (preferencesEditor instanceof PreferencesEditor) {
|
||||
preferencesEditor.focusSettingsFileEditor();
|
||||
} else if (preferencesEditor) {
|
||||
preferencesEditor.focusSettings();
|
||||
}
|
||||
}
|
||||
});
|
||||
focusSettingsFromSearchCommand.register();
|
||||
|
||||
class FocusNextSearchResultCommand extends SettingsCommand {
|
||||
registerAction2(class extends Action2 {
|
||||
constructor() {
|
||||
super({
|
||||
id: SETTINGS_EDITOR_COMMAND_FOCUS_NEXT_SETTING,
|
||||
precondition: CONTEXT_SETTINGS_SEARCH_FOCUS,
|
||||
keybinding: {
|
||||
primary: KeyCode.Enter,
|
||||
weight: KeybindingWeight.EditorContrib,
|
||||
when: null
|
||||
},
|
||||
title: nls.localize('settings.focusNextSetting', "Focus next setting")
|
||||
});
|
||||
}
|
||||
|
||||
runCommand(accessor: ServicesAccessor, args: any): void {
|
||||
const preferencesEditor = this.getPreferencesEditor(accessor);
|
||||
run(accessor: ServicesAccessor): void {
|
||||
const preferencesEditor = getPreferencesEditor(accessor);
|
||||
if (preferencesEditor instanceof PreferencesEditor) {
|
||||
preferencesEditor.focusNextResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
const focusNextSearchResultCommand = new FocusNextSearchResultCommand({
|
||||
id: SETTINGS_EDITOR_COMMAND_FOCUS_NEXT_SETTING,
|
||||
precondition: CONTEXT_SETTINGS_SEARCH_FOCUS,
|
||||
kbOpts: { primary: KeyCode.Enter, weight: KeybindingWeight.EditorContrib }
|
||||
});
|
||||
focusNextSearchResultCommand.register();
|
||||
|
||||
class FocusPreviousSearchResultCommand extends SettingsCommand {
|
||||
registerAction2(class extends Action2 {
|
||||
constructor() {
|
||||
super({
|
||||
id: SETTINGS_EDITOR_COMMAND_FOCUS_PREVIOUS_SETTING,
|
||||
precondition: CONTEXT_SETTINGS_SEARCH_FOCUS,
|
||||
keybinding: {
|
||||
primary: KeyMod.Shift | KeyCode.Enter,
|
||||
weight: KeybindingWeight.EditorContrib,
|
||||
when: null
|
||||
},
|
||||
title: nls.localize('settings.focusPreviousSetting', "Focus previous setting")
|
||||
});
|
||||
}
|
||||
|
||||
runCommand(accessor: ServicesAccessor, args: any): void {
|
||||
const preferencesEditor = this.getPreferencesEditor(accessor);
|
||||
run(accessor: ServicesAccessor): void {
|
||||
const preferencesEditor = getPreferencesEditor(accessor);
|
||||
if (preferencesEditor instanceof PreferencesEditor) {
|
||||
preferencesEditor.focusPreviousResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
const focusPreviousSearchResultCommand = new FocusPreviousSearchResultCommand({
|
||||
id: SETTINGS_EDITOR_COMMAND_FOCUS_PREVIOUS_SETTING,
|
||||
precondition: CONTEXT_SETTINGS_SEARCH_FOCUS,
|
||||
kbOpts: { primary: KeyMod.Shift | KeyCode.Enter, weight: KeybindingWeight.EditorContrib }
|
||||
});
|
||||
focusPreviousSearchResultCommand.register();
|
||||
|
||||
class EditFocusedSettingCommand extends SettingsCommand {
|
||||
registerAction2(class extends Action2 {
|
||||
constructor() {
|
||||
super({
|
||||
id: SETTINGS_EDITOR_COMMAND_EDIT_FOCUSED_SETTING,
|
||||
precondition: CONTEXT_SETTINGS_SEARCH_FOCUS,
|
||||
keybinding: {
|
||||
primary: KeyMod.CtrlCmd | KeyCode.US_DOT,
|
||||
weight: KeybindingWeight.EditorContrib,
|
||||
when: null
|
||||
},
|
||||
title: nls.localize('settings.editFocusedSetting', "Edit focused setting")
|
||||
});
|
||||
}
|
||||
|
||||
runCommand(accessor: ServicesAccessor, args: any): void {
|
||||
const preferencesEditor = this.getPreferencesEditor(accessor);
|
||||
run(accessor: ServicesAccessor): void {
|
||||
const preferencesEditor = getPreferencesEditor(accessor);
|
||||
if (preferencesEditor instanceof PreferencesEditor) {
|
||||
preferencesEditor.editFocusedPreference();
|
||||
}
|
||||
}
|
||||
}
|
||||
const editFocusedSettingCommand = new EditFocusedSettingCommand({
|
||||
id: SETTINGS_EDITOR_COMMAND_EDIT_FOCUSED_SETTING,
|
||||
precondition: CONTEXT_SETTINGS_SEARCH_FOCUS,
|
||||
kbOpts: { primary: KeyMod.CtrlCmd | KeyCode.US_DOT, weight: KeybindingWeight.EditorContrib }
|
||||
});
|
||||
editFocusedSettingCommand.register();
|
||||
|
||||
class FocusSettingsListCommand extends SettingsCommand {
|
||||
registerAction2(class extends Action2 {
|
||||
constructor() {
|
||||
super({
|
||||
id: SETTINGS_EDITOR_COMMAND_FOCUS_SETTINGS_LIST,
|
||||
precondition: ContextKeyExpr.and(CONTEXT_SETTINGS_EDITOR, CONTEXT_TOC_ROW_FOCUS),
|
||||
keybinding: {
|
||||
primary: KeyCode.Enter,
|
||||
weight: KeybindingWeight.WorkbenchContrib,
|
||||
when: null
|
||||
},
|
||||
title: nls.localize('settings.focusSettingsList', "Focus settings list")
|
||||
});
|
||||
}
|
||||
|
||||
runCommand(accessor: ServicesAccessor, args: any): void {
|
||||
const preferencesEditor = this.getPreferencesEditor(accessor);
|
||||
run(accessor: ServicesAccessor): void {
|
||||
const preferencesEditor = getPreferencesEditor(accessor);
|
||||
if (preferencesEditor instanceof SettingsEditor2) {
|
||||
preferencesEditor.focusSettings();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const focusSettingsListCommand = new FocusSettingsListCommand({
|
||||
id: SETTINGS_EDITOR_COMMAND_FOCUS_SETTINGS_LIST,
|
||||
precondition: ContextKeyExpr.and(CONTEXT_SETTINGS_EDITOR, CONTEXT_TOC_ROW_FOCUS),
|
||||
kbOpts: { primary: KeyCode.Enter, weight: KeybindingWeight.WorkbenchContrib }
|
||||
});
|
||||
focusSettingsListCommand.register();
|
||||
|
||||
class ShowContextMenuCommand extends SettingsCommand {
|
||||
runCommand(accessor: ServicesAccessor, args: any): void {
|
||||
const preferencesEditor = this.getPreferencesEditor(accessor);
|
||||
registerAction2(class extends Action2 {
|
||||
constructor() {
|
||||
super({
|
||||
id: SETTINGS_EDITOR_COMMAND_SHOW_CONTEXT_MENU,
|
||||
precondition: ContextKeyExpr.and(CONTEXT_SETTINGS_EDITOR),
|
||||
keybinding: {
|
||||
primary: KeyMod.Shift | KeyCode.F9,
|
||||
weight: KeybindingWeight.WorkbenchContrib,
|
||||
when: null
|
||||
},
|
||||
title: nls.localize('settings.showContextMenu', "Show context menu")
|
||||
});
|
||||
}
|
||||
|
||||
run(accessor: ServicesAccessor): void {
|
||||
const preferencesEditor = getPreferencesEditor(accessor);
|
||||
if (preferencesEditor instanceof SettingsEditor2) {
|
||||
preferencesEditor.showContextMenu();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const showContextMenuCommand = new ShowContextMenuCommand({
|
||||
id: SETTINGS_EDITOR_COMMAND_SHOW_CONTEXT_MENU,
|
||||
precondition: ContextKeyExpr.and(CONTEXT_SETTINGS_EDITOR),
|
||||
kbOpts: { primary: KeyMod.Shift | KeyCode.F9, weight: KeybindingWeight.WorkbenchContrib }
|
||||
});
|
||||
showContextMenuCommand.register();
|
||||
|
||||
CommandsRegistry.registerCommand(SETTINGS_EDITOR_COMMAND_SWITCH_TO_JSON, serviceAccessor => {
|
||||
const control = serviceAccessor.get(IEditorService).activeControl as SettingsEditor2;
|
||||
|
||||
@@ -252,7 +252,7 @@ export class PreferencesEditor extends BaseEditor {
|
||||
if (this.editorService.activeControl !== this) {
|
||||
this.focus();
|
||||
}
|
||||
const promise: Promise<boolean> = this.input && this.input.isDirty() ? this.input.save(this.group!.id).then(editor => !!editor) : Promise.resolve(true);
|
||||
const promise: Promise<boolean> = this.input && this.input.isDirty() ? this.editorService.save({ editor: this.input, groupId: this.group!.id }) : Promise.resolve(true);
|
||||
promise.then(() => {
|
||||
if (target === ConfigurationTarget.USER_LOCAL) {
|
||||
this.preferencesService.switchSettings(ConfigurationTarget.USER_LOCAL, this.preferencesService.userSettingsResource, true);
|
||||
|
||||
@@ -1091,7 +1091,8 @@ class WorkspaceConfigurationRenderer extends Disposable {
|
||||
private renderingDelayer: Delayer<void> = new Delayer<void>(200);
|
||||
|
||||
constructor(private editor: ICodeEditor, private workspaceSettingsEditorModel: SettingsEditorModel,
|
||||
@IWorkspaceContextService private readonly workspaceContextService: IWorkspaceContextService
|
||||
@IWorkspaceContextService private readonly workspaceContextService: IWorkspaceContextService,
|
||||
@IMarkerService private readonly markerService: IMarkerService
|
||||
) {
|
||||
super();
|
||||
this._register(this.editor.getModel()!.onDidChangeContent(() => this.renderingDelayer.trigger(() => this.render(this.associatedSettingsEditorModel))));
|
||||
@@ -1099,18 +1100,28 @@ class WorkspaceConfigurationRenderer extends Disposable {
|
||||
|
||||
render(associatedSettingsEditorModel: IPreferencesEditorModel<ISetting>): void {
|
||||
this.associatedSettingsEditorModel = associatedSettingsEditorModel;
|
||||
// Dim other configurations in workspace configuration file only in the context of Settings Editor
|
||||
if (this.associatedSettingsEditorModel && this.workspaceContextService.getWorkbenchState() === WorkbenchState.WORKSPACE && this.workspaceSettingsEditorModel instanceof WorkspaceConfigurationEditorModel) {
|
||||
const markerData: IMarkerData[] = [];
|
||||
if (this.workspaceContextService.getWorkbenchState() === WorkbenchState.WORKSPACE && this.workspaceSettingsEditorModel instanceof WorkspaceConfigurationEditorModel) {
|
||||
const ranges: IRange[] = [];
|
||||
for (const settingsGroup of this.workspaceSettingsEditorModel.configurationGroups) {
|
||||
for (const section of settingsGroup.sections) {
|
||||
for (const setting of section.settings) {
|
||||
if (setting.key !== 'settings') {
|
||||
ranges.push({
|
||||
startLineNumber: setting.keyRange.startLineNumber,
|
||||
startColumn: setting.keyRange.startColumn - 1,
|
||||
endLineNumber: setting.valueRange.endLineNumber,
|
||||
endColumn: setting.valueRange.endColumn
|
||||
if (setting.key === 'folders' || setting.key === 'tasks' || setting.key === 'launch' || setting.key === 'extensions') {
|
||||
if (this.associatedSettingsEditorModel) {
|
||||
// Dim other configurations in workspace configuration file only in the context of Settings Editor
|
||||
ranges.push({
|
||||
startLineNumber: setting.keyRange.startLineNumber,
|
||||
startColumn: setting.keyRange.startColumn - 1,
|
||||
endLineNumber: setting.valueRange.endLineNumber,
|
||||
endColumn: setting.valueRange.endColumn
|
||||
});
|
||||
}
|
||||
} else if (setting.key !== 'settings') {
|
||||
markerData.push({
|
||||
severity: MarkerSeverity.Hint,
|
||||
tags: [MarkerTag.Unnecessary],
|
||||
...setting.range,
|
||||
message: nls.localize('unsupportedProperty', "Unsupported Property")
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1118,6 +1129,11 @@ class WorkspaceConfigurationRenderer extends Disposable {
|
||||
}
|
||||
this.decorationIds = this.editor.deltaDecorations(this.decorationIds, ranges.map(range => this.createDecoration(range)));
|
||||
}
|
||||
if (markerData.length) {
|
||||
this.markerService.changeOne('preferencesEditor', this.workspaceSettingsEditorModel.uri, markerData);
|
||||
} else {
|
||||
this.markerService.remove('preferencesEditor', [this.workspaceSettingsEditorModel.uri]);
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly _DIM_CONFIGURATION_ = ModelDecorationOptions.register({
|
||||
@@ -1133,6 +1149,7 @@ class WorkspaceConfigurationRenderer extends Disposable {
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this.markerService.remove('preferencesEditor', [this.workspaceSettingsEditorModel.uri]);
|
||||
this.decorationIds = this.editor.deltaDecorations(this.decorationIds, []);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -501,7 +501,7 @@ export class SettingsTargetsWidget extends Widget {
|
||||
orientation: ActionsOrientation.HORIZONTAL,
|
||||
ariaLabel: localize('settingsSwitcherBarAriaLabel', "Settings Switcher"),
|
||||
animated: false,
|
||||
actionViewItemProvider: (action: Action) => action.id === 'folderSettings' ? this.folderSettings : undefined
|
||||
actionViewItemProvider: (action: IAction) => action.id === 'folderSettings' ? this.folderSettings : undefined
|
||||
}));
|
||||
|
||||
this.userLocalSettings = new Action('userSettings', localize('userSettings', "User"), '.settings-tab', true, () => this.updateTarget(ConfigurationTarget.USER_LOCAL));
|
||||
|
||||
@@ -174,6 +174,11 @@ export const tocData: ITOCEntry = {
|
||||
id: 'features/remote',
|
||||
label: localize('remote', "Remote"),
|
||||
settings: ['remote.*']
|
||||
},
|
||||
{
|
||||
id: 'features/timeline',
|
||||
label: localize('timeline', "Timeline"),
|
||||
settings: ['timeline.*']
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -42,7 +42,7 @@ import { IOpenerService } from 'vs/platform/opener/common/opener';
|
||||
import { editorBackground, errorForeground, focusBorder, foreground, inputValidationErrorBackground, inputValidationErrorBorder, inputValidationErrorForeground } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { attachButtonStyler, attachInputBoxStyler, attachSelectBoxStyler, attachStyler } from 'vs/platform/theme/common/styler';
|
||||
import { ICssStyleCollector, ITheme, IThemeService, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
|
||||
import { getIgnoredSettings } from 'vs/platform/userDataSync/common/settingsSync';
|
||||
import { getIgnoredSettings } from 'vs/platform/userDataSync/common/settingsMerge';
|
||||
import { ITOCEntry } from 'vs/workbench/contrib/preferences/browser/settingsLayout';
|
||||
import { ISettingsEditorViewState, settingKeyToDisplayFormat, SettingsTreeElement, SettingsTreeGroupChild, SettingsTreeGroupElement, SettingsTreeNewExtensionsElement, SettingsTreeSettingElement } from 'vs/workbench/contrib/preferences/browser/settingsTreeModels';
|
||||
import { ExcludeSettingWidget, IListChangeEvent, IListDataItem, ListSettingWidget, settingsHeaderForeground, settingsNumberInputBackground, settingsNumberInputBorder, settingsNumberInputForeground, settingsSelectBackground, settingsSelectBorder, settingsSelectForeground, settingsSelectListBorder, settingsTextInputBackground, settingsTextInputBorder, settingsTextInputForeground } from 'vs/workbench/contrib/preferences/browser/settingsWidgets';
|
||||
@@ -1190,7 +1190,8 @@ export class SettingTreeRenderers {
|
||||
constructor(
|
||||
@IInstantiationService private readonly _instantiationService: IInstantiationService,
|
||||
@IContextMenuService private readonly _contextMenuService: IContextMenuService,
|
||||
@IContextViewService private readonly _contextViewService: IContextViewService
|
||||
@IContextViewService private readonly _contextViewService: IContextViewService,
|
||||
@IConfigurationService private readonly _configService: IConfigurationService,
|
||||
) {
|
||||
this.settingActions = [
|
||||
new Action('settings.resetSetting', localize('resetSettingLabel', "Reset Setting"), undefined, undefined, (context: SettingsTreeSettingElement) => {
|
||||
@@ -1205,7 +1206,7 @@ export class SettingTreeRenderers {
|
||||
this._instantiationService.createInstance(CopySettingAsJSONAction),
|
||||
];
|
||||
|
||||
const actionFactory = (setting: ISetting) => [this._instantiationService.createInstance(StopSyncingSettingAction, setting)];
|
||||
const actionFactory = (setting: ISetting) => this.getActionsForSetting(setting);
|
||||
const settingRenderers = [
|
||||
this._instantiationService.createInstance(SettingBoolRenderer, this.settingActions, actionFactory),
|
||||
this._instantiationService.createInstance(SettingNumberRenderer, this.settingActions, actionFactory),
|
||||
@@ -1233,6 +1234,13 @@ export class SettingTreeRenderers {
|
||||
];
|
||||
}
|
||||
|
||||
private getActionsForSetting(setting: ISetting): IAction[] {
|
||||
const enableSync = this._configService.getValue<boolean>('sync.enable');
|
||||
return enableSync ?
|
||||
[this._instantiationService.createInstance(StopSyncingSettingAction, setting)] :
|
||||
[];
|
||||
}
|
||||
|
||||
cancelSuggesters() {
|
||||
this._contextViewService.hideContextView();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user