|
6 | 6 | import { KeyChord, KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
7 | 7 | import { Disposable, DisposableStore, MutableDisposable } from 'vs/base/common/lifecycle';
|
8 | 8 | import { Schemas } from 'vs/base/common/network';
|
9 |
| -import { isObject } from 'vs/base/common/types'; |
| 9 | +import { isBoolean, isObject, isString } from 'vs/base/common/types'; |
10 | 10 | import { URI } from 'vs/base/common/uri';
|
11 | 11 | import 'vs/css!./media/preferences';
|
12 | 12 | import { EditorContributionInstantiation, registerEditorContribution } from 'vs/editor/browser/editorExtensions';
|
@@ -126,17 +126,43 @@ const category = { value: nls.localize('preferences', "Preferences"), original:
|
126 | 126 | interface IOpenSettingsActionOptions {
|
127 | 127 | openToSide?: boolean;
|
128 | 128 | query?: string;
|
| 129 | + revealSetting?: { |
| 130 | + key: string; |
| 131 | + edit?: boolean; |
| 132 | + }; |
| 133 | + focusSearch?: boolean; |
| 134 | +} |
| 135 | + |
| 136 | +function sanitizeBoolean(arg: any): boolean | undefined { |
| 137 | + return isBoolean(arg) ? arg : undefined; |
| 138 | +} |
| 139 | + |
| 140 | +function sanitizeString(arg: any): string | undefined { |
| 141 | + return isString(arg) ? arg : undefined; |
129 | 142 | }
|
130 | 143 |
|
131 | 144 | function sanitizeOpenSettingsArgs(args: any): IOpenSettingsActionOptions {
|
132 | 145 | if (!isObject(args)) {
|
133 | 146 | args = {};
|
134 | 147 | }
|
135 | 148 |
|
136 |
| - return { |
137 |
| - openToSide: args.openToSide, |
138 |
| - query: args.query |
| 149 | + let sanitizedObject: IOpenSettingsActionOptions = { |
| 150 | + focusSearch: sanitizeBoolean(args?.focusSearch), |
| 151 | + openToSide: sanitizeBoolean(args?.openToSide), |
| 152 | + query: sanitizeString(args?.query) |
139 | 153 | };
|
| 154 | + |
| 155 | + if (isString(args?.revealSetting?.key)) { |
| 156 | + sanitizedObject = { |
| 157 | + ...sanitizedObject, |
| 158 | + revealSetting: { |
| 159 | + key: args.revealSetting.key, |
| 160 | + edit: sanitizeBoolean(args.revealSetting?.edit) |
| 161 | + } |
| 162 | + }; |
| 163 | + } |
| 164 | + |
| 165 | + return sanitizedObject; |
140 | 166 | }
|
141 | 167 |
|
142 | 168 | class PreferencesActionsContribution extends Disposable implements IWorkbenchContribution {
|
|
0 commit comments