diff --git a/extensions/git/src/model.ts b/extensions/git/src/model.ts index a199e010be6..0fe0055e5a6 100644 --- a/extensions/git/src/model.ts +++ b/extensions/git/src/model.ts @@ -539,6 +539,7 @@ export class Model implements IRepositoryResolver, IBranchProtectionProviderRegi if (textEditor === undefined) { commands.executeCommand('setContext', 'git.activeResourceHasUnstagedChanges', false); commands.executeCommand('setContext', 'git.activeResourceHasStagedChanges', false); + commands.executeCommand('setContext', 'git.activeResourceHasMergeConflicts', false); return; } @@ -546,6 +547,7 @@ export class Model implements IRepositoryResolver, IBranchProtectionProviderRegi if (!repository) { commands.executeCommand('setContext', 'git.activeResourceHasUnstagedChanges', false); commands.executeCommand('setContext', 'git.activeResourceHasStagedChanges', false); + commands.executeCommand('setContext', 'git.activeResourceHasMergeConflicts', false); return; } @@ -553,9 +555,13 @@ export class Model implements IRepositoryResolver, IBranchProtectionProviderRegi .find(resource => pathEquals(resource.resourceUri.fsPath, textEditor.document.uri.fsPath)); const workingTreeResource = repository.workingTreeGroup.resourceStates .find(resource => pathEquals(resource.resourceUri.fsPath, textEditor.document.uri.fsPath)); + const mergeChangesResource = repository.mergeGroup.resourceStates + .find(resource => pathEquals(resource.resourceUri.fsPath, textEditor.document.uri.fsPath)); + const hasMergeConflicts = mergeChangesResource ? /^(<{7,}|={7,}|>{7,})/m.test(textEditor.document.getText()) : false; commands.executeCommand('setContext', 'git.activeResourceHasStagedChanges', indexResource !== undefined); commands.executeCommand('setContext', 'git.activeResourceHasUnstagedChanges', workingTreeResource !== undefined); + commands.executeCommand('setContext', 'git.activeResourceHasMergeConflicts', hasMergeConflicts); } @sequentialize diff --git a/src/vs/workbench/contrib/scm/browser/scm.contribution.ts b/src/vs/workbench/contrib/scm/browser/scm.contribution.ts index 284fcd9072c..ab967ecfbfe 100644 --- a/src/vs/workbench/contrib/scm/browser/scm.contribution.ts +++ b/src/vs/workbench/contrib/scm/browser/scm.contribution.ts @@ -660,7 +660,7 @@ registerAction2(class extends Action2 { ChatContextKeys.Setup.hidden.negate(), ChatContextKeys.Setup.disabled.negate(), ChatContextKeys.Setup.installed.negate(), - ContextKeyExpr.greater('mergeConflictsCount', 0) + ContextKeyExpr.equals('git.activeResourceHasMergeConflicts', true) ) } });