Git - add stage/unstage commands to editor title (#237257)
parent
2bdb3e9b41
commit
aa6a38114c
|
@ -2050,9 +2050,19 @@
|
||||||
"group": "navigation",
|
"group": "navigation",
|
||||||
"when": "config.git.enabled && !git.missing && gitOpenRepositoryCount != 0 && isInNotebookTextDiffEditor && resourceScheme =~ /^git$|^file$/"
|
"when": "config.git.enabled && !git.missing && gitOpenRepositoryCount != 0 && isInNotebookTextDiffEditor && resourceScheme =~ /^git$|^file$/"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"command": "git.stage",
|
||||||
|
"group": "navigation@1",
|
||||||
|
"when": "config.git.enabled && !git.missing && gitOpenRepositoryCount != 0 && !isInDiffEditor && !isMergeEditor && resourceScheme == file && git.activeResourceHasUnstagedChanges"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "git.unstage",
|
||||||
|
"group": "navigation@1",
|
||||||
|
"when": "config.git.enabled && !git.missing && gitOpenRepositoryCount != 0 && !isInDiffEditor && !isMergeEditor && resourceScheme == file && git.activeResourceHasStagedChanges"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"command": "git.openChange",
|
"command": "git.openChange",
|
||||||
"group": "navigation",
|
"group": "navigation@2",
|
||||||
"when": "config.git.enabled && !git.missing && gitOpenRepositoryCount != 0 && !isInDiffEditor && !isMergeEditor && resourceScheme == file && scmActiveResourceHasChanges"
|
"when": "config.git.enabled && !git.missing && gitOpenRepositoryCount != 0 && !isInDiffEditor && !isMergeEditor && resourceScheme == file && scmActiveResourceHasChanges"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -272,6 +272,7 @@ export class Model implements IRepositoryResolver, IBranchProtectionProviderRegi
|
||||||
|
|
||||||
workspace.onDidChangeWorkspaceFolders(this.onDidChangeWorkspaceFolders, this, this.disposables);
|
workspace.onDidChangeWorkspaceFolders(this.onDidChangeWorkspaceFolders, this, this.disposables);
|
||||||
window.onDidChangeVisibleTextEditors(this.onDidChangeVisibleTextEditors, this, this.disposables);
|
window.onDidChangeVisibleTextEditors(this.onDidChangeVisibleTextEditors, this, this.disposables);
|
||||||
|
window.onDidChangeActiveTextEditor(this.onDidChangeActiveTextEditor, this, this.disposables);
|
||||||
workspace.onDidChangeConfiguration(this.onDidChangeConfiguration, this, this.disposables);
|
workspace.onDidChangeConfiguration(this.onDidChangeConfiguration, this, this.disposables);
|
||||||
|
|
||||||
const fsWatcher = workspace.createFileSystemWatcher('**');
|
const fsWatcher = workspace.createFileSystemWatcher('**');
|
||||||
|
@ -519,6 +520,31 @@ export class Model implements IRepositoryResolver, IBranchProtectionProviderRegi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private onDidChangeActiveTextEditor(): void {
|
||||||
|
const textEditor = window.activeTextEditor;
|
||||||
|
|
||||||
|
if (textEditor === undefined) {
|
||||||
|
commands.executeCommand('setContext', 'git.activeResourceHasUnstagedChanges', false);
|
||||||
|
commands.executeCommand('setContext', 'git.activeResourceHasStagedChanges', false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const repository = this.getRepository(textEditor.document.uri);
|
||||||
|
if (!repository) {
|
||||||
|
commands.executeCommand('setContext', 'git.activeResourceHasUnstagedChanges', false);
|
||||||
|
commands.executeCommand('setContext', 'git.activeResourceHasStagedChanges', false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const indexResource = repository.indexGroup.resourceStates
|
||||||
|
.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));
|
||||||
|
|
||||||
|
commands.executeCommand('setContext', 'git.activeResourceHasStagedChanges', indexResource !== undefined);
|
||||||
|
commands.executeCommand('setContext', 'git.activeResourceHasUnstagedChanges', workingTreeResource !== undefined);
|
||||||
|
}
|
||||||
|
|
||||||
@sequentialize
|
@sequentialize
|
||||||
async openRepository(repoPath: string, openIfClosed = false): Promise<void> {
|
async openRepository(repoPath: string, openIfClosed = false): Promise<void> {
|
||||||
this.logger.trace(`[Model][openRepository] Repository: ${repoPath}`);
|
this.logger.trace(`[Model][openRepository] Repository: ${repoPath}`);
|
||||||
|
@ -727,8 +753,10 @@ export class Model implements IRepositoryResolver, IBranchProtectionProviderRegi
|
||||||
const statusListener = repository.onDidRunGitStatus(() => {
|
const statusListener = repository.onDidRunGitStatus(() => {
|
||||||
checkForSubmodules();
|
checkForSubmodules();
|
||||||
updateMergeChanges();
|
updateMergeChanges();
|
||||||
|
this.onDidChangeActiveTextEditor();
|
||||||
});
|
});
|
||||||
checkForSubmodules();
|
checkForSubmodules();
|
||||||
|
this.onDidChangeActiveTextEditor();
|
||||||
|
|
||||||
const updateOperationInProgressContext = () => {
|
const updateOperationInProgressContext = () => {
|
||||||
let operationInProgress = false;
|
let operationInProgress = false;
|
||||||
|
|
Loading…
Reference in New Issue