Git - add context key for merge conflict detection (#268183)

This commit is contained in:
Ladislau Szomoru
2025-09-24 17:33:01 +02:00
committed by GitHub
parent 4e9eba6bad
commit 1a72b133fd
2 changed files with 7 additions and 1 deletions
+6
View File
@@ -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