Skip to content

Commit

Permalink
Add isPositron context key (#5673)
Browse files Browse the repository at this point in the history
  • Loading branch information
timtmok authored Dec 12, 2024
1 parent ab4a431 commit fab84c8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/vs/platform/contextkey/common/contextkey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ CONSTANT_VALUES.set('isEdge', isEdge);
CONSTANT_VALUES.set('isFirefox', isFirefox);
CONSTANT_VALUES.set('isChrome', isChrome);
CONSTANT_VALUES.set('isSafari', isSafari);
// --- Start Positron ---
CONSTANT_VALUES.set('isPositron', true);
// --- End Positron ---

/** allow register constant context keys that are known only after startup; requires running `substituteConstants` on the context key - /~https://github.com/microsoft/vscode/issues/174218#issuecomment-1437972127 */
export function setConstant(key: string, value: boolean) {
Expand Down
4 changes: 4 additions & 0 deletions src/vs/platform/contextkey/common/contextkeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ export const ProductQualityContext = new RawContextKey<string>('productQualityTy

export const InputFocusedContextKey = 'inputFocus';
export const InputFocusedContext = new RawContextKey<boolean>(InputFocusedContextKey, false, localize('inputFocus', "Whether keyboard focus is inside an input box"));

// --- Start Positron ---
export const IsPositronContext = new RawContextKey<boolean>('isPositron', true, localize('isPositron', "Whether the application is Positron"));
// --- End Positron ---
6 changes: 6 additions & 0 deletions src/vs/platform/contextkey/test/common/contextkey.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,4 +376,10 @@ suite('ContextKeyExpr', () => {
)!
));
});

// --- Start Positron ---
test('Positron Context Key', () => {
assert.ok(ContextKeyExpr.has('isPositron').equals(ContextKeyExpr.true()));
});
// --- End Positron ---
});
3 changes: 3 additions & 0 deletions src/vs/workbench/browser/contextkeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic
// eslint-disable-next-line no-duplicate-imports
import { PositronTopActionBarVisibleContext } from 'vs/workbench/common/contextkeys';
// eslint-disable-next-line no-duplicate-imports
import { IsPositronContext } from 'vs/platform/contextkey/common/contextkeys';
// eslint-disable-next-line no-duplicate-imports
import { isTemporaryWorkspace } from 'vs/platform/workspace/common/workspace';
// --- End Positron ---

Expand Down Expand Up @@ -116,6 +118,7 @@ export class WorkbenchContextKeysHandler extends Disposable {
this.virtualWorkspaceContext = VirtualWorkspaceContext.bindTo(this.contextKeyService);
// --- Start Positron ---
this.temporaryWorkspaceContext = TemporaryWorkspaceContext.bindTo(this.contextKeyService);
IsPositronContext.bindTo(this.contextKeyService);
// --- End Positron ---
this.updateWorkspaceContextKeys();

Expand Down

0 comments on commit fab84c8

Please sign in to comment.