Get rid of WordPrefix

This commit is contained in:
Kovid Goyal
2022-11-14 15:41:58 +05:30
parent 0ff2446a1a
commit 3a8bab90dc
3 changed files with 13 additions and 4 deletions
+9 -3
View File
@@ -14,7 +14,6 @@ type MatchGroup struct {
NoTrailingSpace bool `json:"no_trailing_space,omitempty"`
IsFiles bool `json:"is_files,omitempty"`
Matches []*Match `json:"matches,omitempty"`
WordPrefix string `json:"word_prefix,omitempty"`
}
func (self *MatchGroup) add_match(word string, description ...string) *Match {
@@ -24,14 +23,21 @@ func (self *MatchGroup) add_match(word string, description ...string) *Match {
}
type Completions struct {
Groups []*MatchGroup `json:"groups,omitempty"`
WordPrefix string `json:"word_prefix,omitempty"`
Groups []*MatchGroup `json:"groups,omitempty"`
current_cmd *Command
all_words []string // all words passed to parse_args()
current_word_idx int // index of current word in all_words
}
func (self *Completions) add_prefix_to_all_matches(prefix string) {
for _, mg := range self.Groups {
for _, m := range mg.Matches {
m.Word = prefix + m.Word
}
}
}
func (self *Completions) add_match_group(title string) *MatchGroup {
for _, q := range self.Groups {
if q.Title == title {