From e24cd86a0136a341c0db3ce23296ed0787615dac Mon Sep 17 00:00:00 2001 From: Alex Ross Date: Tue, 17 Dec 2024 11:58:58 +0100 Subject: [PATCH] Better openDiffOnClick+showInlineOpenFileActions (#6552) Part of #6515 --- package.json | 4 ++-- src/common/settingKeys.ts | 1 + src/extension.ts | 21 ++++++++++++++++++--- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 8679cdaa30..67f70b9773 100644 --- a/package.json +++ b/package.json @@ -2444,12 +2444,12 @@ { "command": "review.openFile", "group": "inline@0", - "when": "openDiffOnClick && view == prStatus:github && viewItem =~ /filechange(?!:DELETE)/ && config.git.showInlineOpenFileAction" + "when": "openDiffOnClick && showInlineOpenFileAction && view == prStatus:github && viewItem =~ /filechange(?!:DELETE)/" }, { "command": "pr.openDiffView", "group": "inline@0", - "when": "!openDiffOnClick && view == prStatus:github && viewItem =~ /filechange(?!:DELETE)/" + "when": "!openDiffOnClick && showInlineOpenFileAction && view == prStatus:github && viewItem =~ /filechange(?!:DELETE)/" }, { "command": "pr.openFileOnGitHub", diff --git a/src/common/settingKeys.ts b/src/common/settingKeys.ts index ac37a80b69..712312812d 100644 --- a/src/common/settingKeys.ts +++ b/src/common/settingKeys.ts @@ -62,6 +62,7 @@ export const EXPERIMENTAL_NOTIFICATIONS_SCORE = 'experimental.notificationsScore export const GIT = 'git'; export const PULL_BEFORE_CHECKOUT = 'pullBeforeCheckout'; export const OPEN_DIFF_ON_CLICK = 'openDiffOnClick'; +export const SHOW_INLINE_OPEN_FILE_ACTION = 'showInlineOpenFileAction'; export const AUTO_STASH = 'autoStash'; // GitHub Enterprise diff --git a/src/extension.ts b/src/extension.ts index 7fbd7551b4..a69fa02d5b 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -15,7 +15,7 @@ import Logger from './common/logger'; import * as PersistentState from './common/persistentState'; import { parseRepositoryRemotes } from './common/remote'; import { Resource } from './common/resources'; -import { BRANCH_PUBLISH, EXPERIMENTAL_CHAT, EXPERIMENTAL_NOTIFICATIONS, FILE_LIST_LAYOUT, GIT, OPEN_DIFF_ON_CLICK, PR_SETTINGS_NAMESPACE } from './common/settingKeys'; +import { BRANCH_PUBLISH, EXPERIMENTAL_CHAT, EXPERIMENTAL_NOTIFICATIONS, FILE_LIST_LAYOUT, GIT, OPEN_DIFF_ON_CLICK, PR_SETTINGS_NAMESPACE, SHOW_INLINE_OPEN_FILE_ACTION } from './common/settingKeys'; import { TemporaryState } from './common/temporaryState'; import { Schemes, handler as uriHandler } from './common/uri'; import { EXTENSION_ID, FOCUS_REVIEW_MODE } from './constants'; @@ -286,8 +286,7 @@ export async function activate(context: vscode.ExtensionContext): Promise void][] = [ + ['openDiffOnClick', () => vscode.workspace.getConfiguration(GIT, null).get(OPEN_DIFF_ON_CLICK, true)], + ['showInlineOpenFileAction', () => vscode.workspace.getConfiguration(GIT, null).get(SHOW_INLINE_OPEN_FILE_ACTION, true)] + ]; + for (const [contextName, setting] of settings) { + commands.setContext(contextName, setting()); + context.subscriptions.push(vscode.workspace.onDidChangeConfiguration(e => { + if (e.affectsConfiguration(`${GIT}.${contextName}`)) { + commands.setContext(contextName, setting()); + } + })); + } +} + async function doRegisterBuiltinGitProvider(context: vscode.ExtensionContext, credentialStore: CredentialStore, apiImpl: GitApiImpl): Promise { const builtInGitProvider = await registerBuiltinGitProvider(credentialStore, apiImpl); if (builtInGitProvider) {