mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
Make setContext
an API command (#168215)
Fixes #46445: Make `setContext` an API command
This commit is contained in:
parent
07892e4ef2
commit
bafda10a37
|
@ -14,7 +14,7 @@ import { URI } from 'vs/base/common/uri';
|
|||
import { localize } from 'vs/nls';
|
||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { ConfigurationTarget, IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ContextKeyExpression, ContextKeyInfo, ContextKeyValue, IContext, IContextKey, IContextKeyChangeEvent, IContextKeyService, IContextKeyServiceTarget, IReadableSet, RawContextKey, SET_CONTEXT_COMMAND_ID } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ContextKeyExpression, ContextKeyInfo, ContextKeyValue, IContext, IContextKey, IContextKeyChangeEvent, IContextKeyService, IContextKeyServiceTarget, IReadableSet, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
const KEYBINDING_CONTEXT_ATTR = 'data-keybinding-context';
|
||||
|
@ -619,7 +619,7 @@ function stringifyURIs(contextValue: any): any {
|
|||
});
|
||||
}
|
||||
|
||||
CommandsRegistry.registerCommand(SET_CONTEXT_COMMAND_ID, setContext);
|
||||
CommandsRegistry.registerCommand('_setContext', setContext);
|
||||
|
||||
CommandsRegistry.registerCommand({
|
||||
id: 'getContextKeyInfo',
|
||||
|
|
|
@ -1647,8 +1647,6 @@ export interface IContextKeyService {
|
|||
updateParent(parentContextKeyService: IContextKeyService): void;
|
||||
}
|
||||
|
||||
export const SET_CONTEXT_COMMAND_ID = 'setContext';
|
||||
|
||||
function cmp1(key1: string, key2: string): number {
|
||||
if (key1 < key2) {
|
||||
return -1;
|
||||
|
|
|
@ -442,6 +442,15 @@ const newCommands: ApiCommand[] = [
|
|||
'vscode.experimental.editSession.continue', '_workbench.editSessions.actions.continueEditSession', 'Continue the current edit session in a different workspace',
|
||||
[ApiCommandArgument.Uri.with('workspaceUri', 'The target workspace to continue the current edit session in')],
|
||||
ApiCommandResult.Void
|
||||
),
|
||||
// --- context keys
|
||||
new ApiCommand(
|
||||
'setContext', '_setContext', 'Set a custom context key value that can be used in when clauses.',
|
||||
[
|
||||
ApiCommandArgument.String.with('name', 'The context key name'),
|
||||
new ApiCommandArgument('value', 'The context key value', () => true, v => v),
|
||||
],
|
||||
ApiCommandResult.Void
|
||||
)
|
||||
];
|
||||
|
||||
|
|
Loading…
Reference in a new issue