Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git - fix commitInProgress context key #162562

Merged
merged 1 commit into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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