Skip to content

Commit

Permalink
Add progress indicator to SCM in activity bar while QuickDiff is pre…
Browse files Browse the repository at this point in the history
…paring (#136968) (#136969)
  • Loading branch information
gjsjohnmurray committed Nov 12, 2021
1 parent 2dcc582 commit 5f4830b
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import { gotoNextLocation, gotoPreviousLocation } from 'vs/platform/theme/common
import { Codicon } from 'vs/base/common/codicons';
import { onUnexpectedError } from 'vs/base/common/errors';
import { TextCompareEditorActiveContext } from 'vs/workbench/common/editor';
import { IProgressService, ProgressLocation } from 'vs/platform/progress/common/progress';

class DiffActionRunner extends ActionRunner {

Expand Down Expand Up @@ -1088,7 +1089,8 @@ export class DirtyDiffModel extends Disposable {
@ISCMService private readonly scmService: ISCMService,
@IEditorWorkerService private readonly editorWorkerService: IEditorWorkerService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@ITextModelService private readonly textModelResolverService: ITextModelService
@ITextModelService private readonly textModelResolverService: ITextModelService,
@IProgressService private readonly progressService: IProgressService,
) {
super();
this._model = textFileModel;
Expand Down Expand Up @@ -1160,21 +1162,23 @@ export class DirtyDiffModel extends Disposable {
}

private diff(): Promise<IChange[] | null> {
return this.getOriginalURIPromise().then(originalURI => {
if (this._disposed || this._model.isDisposed() || !originalURI) {
return Promise.resolve([]); // disposed
}
return this.progressService.withProgress({ location: ProgressLocation.Scm }, async () => {
return this.getOriginalURIPromise().then(originalURI => {
if (this._disposed || this._model.isDisposed() || !originalURI) {
return Promise.resolve([]); // disposed
}

if (!this.editorWorkerService.canComputeDirtyDiff(originalURI, this._model.resource)) {
return Promise.resolve([]); // Files too large
}
if (!this.editorWorkerService.canComputeDirtyDiff(originalURI, this._model.resource)) {
return Promise.resolve([]); // Files too large
}

const ignoreTrimWhitespaceSetting = this.configurationService.getValue<'true' | 'false' | 'inherit'>('scm.diffDecorationsIgnoreTrimWhitespace');
const ignoreTrimWhitespace = ignoreTrimWhitespaceSetting === 'inherit'
? this.configurationService.getValue<boolean>('diffEditor.ignoreTrimWhitespace')
: ignoreTrimWhitespaceSetting !== 'false';
const ignoreTrimWhitespaceSetting = this.configurationService.getValue<'true' | 'false' | 'inherit'>('scm.diffDecorationsIgnoreTrimWhitespace');
const ignoreTrimWhitespace = ignoreTrimWhitespaceSetting === 'inherit'
? this.configurationService.getValue<boolean>('diffEditor.ignoreTrimWhitespace')
: ignoreTrimWhitespaceSetting !== 'false';

return this.editorWorkerService.computeDirtyDiff(originalURI, this._model.resource, ignoreTrimWhitespace);
return this.editorWorkerService.computeDirtyDiff(originalURI, this._model.resource, ignoreTrimWhitespace);
});
});
}

Expand Down

0 comments on commit 5f4830b

Please sign in to comment.