Skip to content

Commit

Permalink
Git - fix commitInProgress context key (#162562)
Browse files Browse the repository at this point in the history
  • Loading branch information
lszomoru committed Oct 3, 2022
1 parent 3551b7e commit d904014
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
19 changes: 18 additions & 1 deletion extensions/git/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { workspace, WorkspaceFoldersChangeEvent, Uri, window, Event, EventEmitter, QuickPickItem, Disposable, SourceControl, SourceControlResourceGroup, TextEditor, Memento, commands } from 'vscode';
import TelemetryReporter from '@vscode/extension-telemetry';
import { Repository, RepositoryState } from './repository';
import { Operation, Repository, RepositoryState } from './repository';
import { memoize, sequentialize, debounce } from './decorators';
import { dispose, anyEvent, filterEvent, isDescendant, pathEquals, toDisposable, eventToPromise } from './util';
import { Git } from './git';
Expand Down Expand Up @@ -467,11 +467,28 @@ export class Model implements IRemoteSourcePublisherRegistry, IPostCommitCommand
});
checkForSubmodules();

const updateCommitInProgressContext = () => {
let commitInProgress = false;
for (const { repository } of this.openRepositories.values()) {
if (repository.operations.isRunning(Operation.Commit)) {
commitInProgress = true;
break;
}
}

commands.executeCommand('setContext', 'commitInProgress', commitInProgress);
};

const operationEvent = anyEvent(repository.onDidRunOperation as Event<any>, repository.onRunOperation as Event<any>);
const operationListener = operationEvent(() => updateCommitInProgressContext());
updateCommitInProgressContext();

const dispose = () => {
disappearListener.dispose();
changeListener.dispose();
originalResourceChangeListener.dispose();
statusListener.dispose();
operationListener.dispose();
repository.dispose();

this.openRepositories = this.openRepositories.filter(e => e !== openRepository);
Expand Down
6 changes: 2 additions & 4 deletions extensions/git/src/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,10 +460,8 @@ class ProgressManager {
this.updateEnablement();

this.repository.onDidChangeOperations(() => {
const commitInProgress = this.repository.operations.isRunning(Operation.Commit);

this.repository.sourceControl.inputBox.enabled = !commitInProgress;
commands.executeCommand('setContext', 'commitInProgress', commitInProgress);
// Disable input box when the commit operation is running
this.repository.sourceControl.inputBox.enabled = !this.repository.operations.isRunning(Operation.Commit);
});
}

Expand Down

0 comments on commit d904014

Please sign in to comment.