Skip to content

Commit 9268d88

Browse files
committed
Move git branch boost below main score check
1 parent 46b0380 commit 9268d88

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/vs/workbench/contrib/terminalContrib/suggest/browser/terminalCompletionModel.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,6 @@ const compareCompletionsFn = (leadingLineContent: string, a: TerminalCompletionI
3838
return 1;
3939
}
4040

41-
// Boost main and master branches for git commands
42-
// HACK: Currently this just matches leading line content, it should eventually check the
43-
// completion type is a branch
44-
if (a.completion.kind === TerminalCompletionItemKind.Method && b.completion.kind === TerminalCompletionItemKind.Method && /^\s*git\b/.test(leadingLineContent)) {
45-
const aLabel = typeof a.completion.label === 'string' ? a.completion.label : a.completion.label.label;
46-
const bLabel = typeof b.completion.label === 'string' ? b.completion.label : b.completion.label.label;
47-
const aIsMainOrMaster = aLabel === 'main' || aLabel === 'master';
48-
const bIsMainOrMaster = bLabel === 'main' || bLabel === 'master';
49-
50-
if (aIsMainOrMaster && !bIsMainOrMaster) {
51-
return -1;
52-
}
53-
if (bIsMainOrMaster && !aIsMainOrMaster) {
54-
return 1;
55-
}
56-
}
57-
5841
// Sort by the score
5942
let score = b.score[0] - a.score[0];
6043
if (score !== 0) {
@@ -98,6 +81,23 @@ const compareCompletionsFn = (leadingLineContent: string, a: TerminalCompletionI
9881
}
9982
}
10083

84+
// Boost main and master branches for git commands
85+
// HACK: Currently this just matches leading line content, it should eventually check the
86+
// completion type is a branch
87+
if (a.completion.kind === TerminalCompletionItemKind.Method && b.completion.kind === TerminalCompletionItemKind.Method && /^\s*git\b/.test(leadingLineContent)) {
88+
const aLabel = typeof a.completion.label === 'string' ? a.completion.label : a.completion.label.label;
89+
const bLabel = typeof b.completion.label === 'string' ? b.completion.label : b.completion.label.label;
90+
const aIsMainOrMaster = aLabel === 'main' || aLabel === 'master';
91+
const bIsMainOrMaster = bLabel === 'main' || bLabel === 'master';
92+
93+
if (aIsMainOrMaster && !bIsMainOrMaster) {
94+
return -1;
95+
}
96+
if (bIsMainOrMaster && !aIsMainOrMaster) {
97+
return 1;
98+
}
99+
}
100+
101101
// Sort by more detailed completions
102102
if (a.completion.kind === TerminalCompletionItemKind.Method && b.completion.kind === TerminalCompletionItemKind.Method) {
103103
if (typeof a.completion.label !== 'string' && a.completion.label.description && typeof b.completion.label !== 'string' && b.completion.label.description) {

0 commit comments

Comments
 (0)