Skip to content

Commit b4fbff3

Browse files
authored
Git - Don't show progress for commands that support optimistic UI updates (microsoft#166124)
Don't show progress for commands that support optimistic UI updates
1 parent f08b79d commit b4fbff3

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

extensions/git/src/repository.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,11 +308,14 @@ export const enum Operation {
308308
Diff = 'Diff',
309309
MergeBase = 'MergeBase',
310310
Add = 'Add',
311+
AddNoProgress = 'AddNoProgress',
311312
Remove = 'Remove',
312313
RevertFiles = 'RevertFiles',
314+
RevertFilesNoProgress = 'RevertFilesNoProgress',
313315
Commit = 'Commit',
314316
PostCommitCommand = 'PostCommitCommand',
315317
Clean = 'Clean',
318+
CleanNoProgress = 'CleanNoProgress',
316319
Branch = 'Branch',
317320
GetBranch = 'GetBranch',
318321
GetBranches = 'GetBranches',
@@ -376,7 +379,10 @@ function isReadOnly(operation: Operation): boolean {
376379

377380
function shouldShowProgress(operation: Operation): boolean {
378381
switch (operation) {
382+
case Operation.AddNoProgress:
383+
case Operation.CleanNoProgress:
379384
case Operation.FetchNoProgress:
385+
case Operation.RevertFilesNoProgress:
380386
case Operation.CheckIgnore:
381387
case Operation.GetObjectDetails:
382388
case Operation.Show:
@@ -1225,8 +1231,12 @@ export class Repository implements Disposable {
12251231
}
12261232

12271233
async add(resources: Uri[], opts?: { update?: boolean }): Promise<void> {
1234+
const config = workspace.getConfiguration('git', Uri.file(this.root));
1235+
const optimisticUpdate = config.get<boolean>('optimisticUpdate') === true;
1236+
const operation = optimisticUpdate ? Operation.AddNoProgress : Operation.Add;
1237+
12281238
await this.run(
1229-
Operation.Add,
1239+
operation,
12301240
async () => {
12311241
await this.repository.add(resources.map(r => r.fsPath), opts);
12321242
this.closeDiffEditors([], [...resources.map(r => r.fsPath)]);
@@ -1276,8 +1286,12 @@ export class Repository implements Disposable {
12761286
}
12771287

12781288
async revert(resources: Uri[]): Promise<void> {
1289+
const config = workspace.getConfiguration('git', Uri.file(this.root));
1290+
const optimisticUpdate = config.get<boolean>('optimisticUpdate') === true;
1291+
const operation = optimisticUpdate ? Operation.RevertFilesNoProgress : Operation.RevertFiles;
1292+
12791293
await this.run(
1280-
Operation.RevertFiles,
1294+
operation,
12811295
async () => {
12821296
await this.repository.revert('HEAD', resources.map(r => r.fsPath));
12831297
this.closeDiffEditors([...resources.length !== 0 ?
@@ -1387,8 +1401,12 @@ export class Repository implements Disposable {
13871401
}
13881402

13891403
async clean(resources: Uri[]): Promise<void> {
1404+
const config = workspace.getConfiguration('git', Uri.file(this.root));
1405+
const optimisticUpdate = config.get<boolean>('optimisticUpdate') === true;
1406+
const operation = optimisticUpdate ? Operation.CleanNoProgress : Operation.Clean;
1407+
13901408
await this.run(
1391-
Operation.Clean,
1409+
operation,
13921410
async () => {
13931411
const toClean: string[] = [];
13941412
const toCheckout: string[] = [];

0 commit comments

Comments
 (0)