Skip to content

Commit 3825a2a

Browse files
committed
fix: align git status parser with ref order
Change-Id: I7afe82dc1d8eb76f0c78bd6c60571a7460dfcf55 Signed-off-by: Thomas Kosiewski <tk@coder.com>
1 parent 9949638 commit 3825a2a

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/utils/git/parseGitStatus.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,18 @@ export function parseGitShowBranchForStatus(
7373
const branchColumns = new Map<string, number>();
7474

7575
for (const line of headerLines) {
76-
const headerMatch = /^(\s*)[!*+]\s+\[([^\]]+)\]/.exec(line);
77-
if (!headerMatch) {
76+
const indicatorIndex = line.search(/[!*+]/);
77+
if (indicatorIndex === -1) {
7878
continue;
7979
}
8080

81-
const [, leadingSpaces, branchName] = headerMatch;
82-
branchColumns.set(branchName, leadingSpaces.length);
81+
const branchNameMatch = /\[([^\]]+)\]/.exec(line);
82+
if (!branchNameMatch) {
83+
continue;
84+
}
85+
86+
const [, branchName] = branchNameMatch;
87+
branchColumns.set(branchName, indicatorIndex);
8388
}
8489

8590
const headColumn = branchColumns.get("HEAD");

0 commit comments

Comments
 (0)