Skip to content

Commit c69f654

Browse files
committed
Fix being reset to "Show All" when switching branches.
1 parent a492007 commit c69f654

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

web/main.ts

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -256,14 +256,18 @@ class GitGraphView {
256256
// Update the state of the fetch button
257257
this.renderFetchButton();
258258

259-
// Configure current branches
260-
if (this.currentBranches !== null && !(this.currentBranches.length === 1 && this.currentBranches[0] === SHOW_ALL_BRANCHES)) {
261-
// Filter any branches that are currently selected, but no longer exist
262-
const globPatterns = this.config.customBranchGlobPatterns.map((pattern) => pattern.glob);
263-
this.currentBranches = this.currentBranches.filter((branch) =>
264-
this.gitBranches.includes(branch) || globPatterns.includes(branch)
265-
);
266-
}
259+
const filterCurrentBranches = () => {
260+
// Configure current branches
261+
if (this.currentBranches !== null && !(this.currentBranches.length === 1 && this.currentBranches[0] === SHOW_ALL_BRANCHES)) {
262+
// Filter any branches that are currently selected, but no longer exist
263+
const globPatterns = this.config.customBranchGlobPatterns.map((pattern) => pattern.glob);
264+
this.currentBranches = this.currentBranches.filter((branch) =>
265+
this.gitBranches.includes(branch) || globPatterns.includes(branch) || branch === 'HEAD'
266+
);
267+
}
268+
};
269+
270+
filterCurrentBranches();
267271
if (this.currentBranches === null || this.currentBranches.length === 0) {
268272
// No branches are currently selected
269273
const onRepoLoadShowCheckedOutBranch = getOnRepoLoadShowCheckedOutBranch(this.gitRepos[this.currentRepo].onRepoLoadShowCheckedOutBranch);
@@ -284,15 +288,8 @@ class GitGraphView {
284288
this.currentBranches.push(SHOW_ALL_BRANCHES);
285289
}
286290
}
291+
filterCurrentBranches();
287292

288-
// Configure current branches
289-
if (this.currentBranches !== null && !(this.currentBranches.length === 1 && this.currentBranches[0] === SHOW_ALL_BRANCHES)) {
290-
// Filter any branches that are currently selected, but no longer exist
291-
const globPatterns = this.config.customBranchGlobPatterns.map((pattern) => pattern.glob);
292-
this.currentBranches = this.currentBranches.filter((branch) =>
293-
this.gitBranches.includes(branch) || globPatterns.includes(branch)
294-
);
295-
}
296293
this.saveState();
297294
this.currentAuthors = [];
298295
this.currentAuthors.push(SHOW_ALL_BRANCHES);

0 commit comments

Comments
 (0)