@@ -44,6 +44,23 @@ const compareCompletionsFn = (leadingLineContent: string, a: TerminalCompletionI
44
44
return score ;
45
45
}
46
46
47
+ // Boost main and master branches for git commands (only when scores are equal)
48
+ // HACK: Currently this just matches leading line content, it should eventually check the
49
+ // completion type is a branch
50
+ if ( a . completion . kind === TerminalCompletionItemKind . Method && b . completion . kind === TerminalCompletionItemKind . Method && / ^ \s * g i t \b / . test ( leadingLineContent ) ) {
51
+ const aLabel = typeof a . completion . label === 'string' ? a . completion . label : a . completion . label . label ;
52
+ const bLabel = typeof b . completion . label === 'string' ? b . completion . label : b . completion . label . label ;
53
+ const aIsMainOrMaster = aLabel === 'main' || aLabel === 'master' ;
54
+ const bIsMainOrMaster = bLabel === 'main' || bLabel === 'master' ;
55
+
56
+ if ( aIsMainOrMaster && ! bIsMainOrMaster ) {
57
+ return - 1 ;
58
+ }
59
+ if ( bIsMainOrMaster && ! aIsMainOrMaster ) {
60
+ return 1 ;
61
+ }
62
+ }
63
+
47
64
// Boost inline completions
48
65
if ( a . completion . kind === TerminalCompletionItemKind . InlineSuggestion && a . completion . kind !== b . completion . kind ) {
49
66
return - 1 ;
@@ -81,23 +98,6 @@ const compareCompletionsFn = (leadingLineContent: string, a: TerminalCompletionI
81
98
}
82
99
}
83
100
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 * g i t \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
-
101
101
// Sort by more detailed completions
102
102
if ( a . completion . kind === TerminalCompletionItemKind . Method && b . completion . kind === TerminalCompletionItemKind . Method ) {
103
103
if ( typeof a . completion . label !== 'string' && a . completion . label . description && typeof b . completion . label !== 'string' && b . completion . label . description ) {
0 commit comments