File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ pub struct CompletionCandidate {
10
10
help : Option < StyledStr > ,
11
11
id : Option < String > ,
12
12
tag : Option < StyledStr > ,
13
+ display_order : Option < usize > ,
13
14
hidden : bool ,
14
15
}
15
16
@@ -45,6 +46,12 @@ impl CompletionCandidate {
45
46
self
46
47
}
47
48
49
+ /// Sort weight within a [`CompletionCandidate::tag`]
50
+ pub fn display_order ( mut self , order : Option < usize > ) -> Self {
51
+ self . display_order = order;
52
+ self
53
+ }
54
+
48
55
/// Set the visibility of the completion candidate
49
56
///
50
57
/// Only shown when there is no visible candidate for completing the current argument.
@@ -88,6 +95,11 @@ impl CompletionCandidate {
88
95
self . tag . as_ref ( )
89
96
}
90
97
98
+ /// Get the grouping tag
99
+ pub fn get_display_order ( & self ) -> Option < usize > {
100
+ self . display_order
101
+ }
102
+
91
103
/// Get the visibility of the completion candidate
92
104
pub fn is_hide_set ( & self ) -> bool {
93
105
self . hidden
Original file line number Diff line number Diff line change @@ -286,7 +286,12 @@ fn complete_arg(
286
286
tags. push ( tag) ;
287
287
}
288
288
}
289
- completions. sort_by_key ( |c| tags. iter ( ) . position ( |t| c. get_tag ( ) == t. as_ref ( ) ) ) ;
289
+ completions. sort_by_key ( |c| {
290
+ (
291
+ tags. iter ( ) . position ( |t| c. get_tag ( ) == t. as_ref ( ) ) ,
292
+ c. get_display_order ( ) ,
293
+ )
294
+ } ) ;
290
295
291
296
Ok ( completions)
292
297
}
You can’t perform that action at this time.
0 commit comments