Skip to content

Commit a57fb65

Browse files
committed
Removes Graph debounce for known repo changes
Reduces Graph debounce for other changes to 250ms Updates selected row when HEAD changes Refs: #2298
1 parent b5c7e28 commit a57fb65

2 files changed

Lines changed: 31 additions & 21 deletions

File tree

src/git/models/repository.ts

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,30 +45,30 @@ const millisecondsPerHour = 60 * 60 * 1000;
4545
const millisecondsPerDay = 24 * 60 * 60 * 1000;
4646

4747
export const enum RepositoryChange {
48-
// FileSystem = 'filesystem',
49-
Unknown = 'unknown',
50-
51-
// No file watching required
52-
Closed = 'closed',
53-
Ignores = 'ignores',
54-
Starred = 'starred',
48+
Unknown = -1,
5549

5650
// File watching required
57-
CherryPick = 'cherrypick',
58-
Config = 'config',
59-
Heads = 'heads',
60-
Index = 'index',
61-
Merge = 'merge',
62-
Rebase = 'rebase',
63-
Remotes = 'remotes',
64-
RemoteProviders = 'providers',
65-
Stash = 'stash',
51+
Index = 0,
52+
Head = 1,
53+
Heads = 2,
54+
Tags = 3,
55+
Stash = 4,
56+
Remotes = 5,
57+
Worktrees = 6,
58+
Config = 7,
6659
/*
6760
* Union of Cherry, Merge, and Rebase
6861
*/
69-
Status = 'status',
70-
Tags = 'tags',
71-
Worktrees = 'worktrees',
62+
Status = 8,
63+
CherryPick = 9,
64+
Merge = 10,
65+
Rebase = 11,
66+
67+
// No file watching required
68+
Closed = 100,
69+
Ignores = 101,
70+
RemoteProviders = 102,
71+
Starred = 103,
7272
}
7373

7474
export const enum RepositoryChangeComparisonMode {
@@ -334,6 +334,10 @@ export class Repository implements Disposable {
334334
return;
335335

336336
case 'HEAD':
337+
this.resetCaches('branches');
338+
this.fireChange(RepositoryChange.Head, RepositoryChange.Heads);
339+
return;
340+
337341
case 'ORIG_HEAD':
338342
this.resetCaches('branches');
339343
this.fireChange(RepositoryChange.Heads);

src/plus/webviews/graph/graphWebview.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,7 @@ export class GraphWebview extends WebviewBase<State> {
496496
if (
497497
!e.changed(
498498
RepositoryChange.Config,
499+
RepositoryChange.Head,
499500
RepositoryChange.Heads,
500501
// RepositoryChange.Index,
501502
RepositoryChange.Remotes,
@@ -511,7 +512,12 @@ export class GraphWebview extends WebviewBase<State> {
511512
return;
512513
}
513514

514-
this.updateState();
515+
if (e.changed(RepositoryChange.Head, RepositoryChangeComparisonMode.Any)) {
516+
this.setSelectedRows(undefined);
517+
}
518+
519+
// Unless we don't know what changed, update the state immediately
520+
this.updateState(!e.changed(RepositoryChange.Unknown, RepositoryChangeComparisonMode.Exclusive));
515521
}
516522

517523
@debug({ args: false })
@@ -894,7 +900,7 @@ export class GraphWebview extends WebviewBase<State> {
894900
}
895901

896902
if (this._notifyDidChangeStateDebounced == null) {
897-
this._notifyDidChangeStateDebounced = debounce(this.notifyDidChangeState.bind(this), 500);
903+
this._notifyDidChangeStateDebounced = debounce(this.notifyDidChangeState.bind(this), 250);
898904
}
899905

900906
void this._notifyDidChangeStateDebounced();

0 commit comments

Comments
 (0)