Get rid of WordPrefix
This commit is contained in:
parent
0ff2446a1a
commit
3a8bab90dc
@ -121,6 +121,9 @@ def completion(self: TestCompletion, tdir: str):
|
|||||||
add('kitty -1 ', does_not_have_words('@ls', '@'))
|
add('kitty -1 ', does_not_have_words('@ls', '@'))
|
||||||
add('kitty --directory ', all_words('bin/', 'sub/'))
|
add('kitty --directory ', all_words('bin/', 'sub/'))
|
||||||
add('kitty -1d ', all_words('bin/', 'sub/'))
|
add('kitty -1d ', all_words('bin/', 'sub/'))
|
||||||
|
add('kitty -1d', all_words('-1d'))
|
||||||
|
add('kitty --directory=', all_words('--directory=bin/', '--directory=sub/'))
|
||||||
|
add('kitty --start-as=m', all_words('--start-as=minimized', '--start-as=maximized'))
|
||||||
|
|
||||||
for cmd, tests, result in zip(all_cmds, all_tests, run_tool()):
|
for cmd, tests, result in zip(all_cmds, all_tests, run_tool()):
|
||||||
self.current_cmd = cmd
|
self.current_cmd = cmd
|
||||||
|
|||||||
@ -91,8 +91,8 @@ func complete_word(word string, completions *Completions, only_args_allowed bool
|
|||||||
option := cmd.find_option(word[:idx])
|
option := cmd.find_option(word[:idx])
|
||||||
if option != nil {
|
if option != nil {
|
||||||
if option.Completion_for_arg != nil {
|
if option.Completion_for_arg != nil {
|
||||||
completions.WordPrefix = word[:idx+1]
|
|
||||||
option.Completion_for_arg(completions, word[idx+1:], arg_num)
|
option.Completion_for_arg(completions, word[idx+1:], arg_num)
|
||||||
|
completions.add_prefix_to_all_matches(word[:idx+1])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -14,7 +14,6 @@ type MatchGroup struct {
|
|||||||
NoTrailingSpace bool `json:"no_trailing_space,omitempty"`
|
NoTrailingSpace bool `json:"no_trailing_space,omitempty"`
|
||||||
IsFiles bool `json:"is_files,omitempty"`
|
IsFiles bool `json:"is_files,omitempty"`
|
||||||
Matches []*Match `json:"matches,omitempty"`
|
Matches []*Match `json:"matches,omitempty"`
|
||||||
WordPrefix string `json:"word_prefix,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *MatchGroup) add_match(word string, description ...string) *Match {
|
func (self *MatchGroup) add_match(word string, description ...string) *Match {
|
||||||
@ -25,13 +24,20 @@ func (self *MatchGroup) add_match(word string, description ...string) *Match {
|
|||||||
|
|
||||||
type Completions struct {
|
type Completions struct {
|
||||||
Groups []*MatchGroup `json:"groups,omitempty"`
|
Groups []*MatchGroup `json:"groups,omitempty"`
|
||||||
WordPrefix string `json:"word_prefix,omitempty"`
|
|
||||||
|
|
||||||
current_cmd *Command
|
current_cmd *Command
|
||||||
all_words []string // all words passed to parse_args()
|
all_words []string // all words passed to parse_args()
|
||||||
current_word_idx int // index of current word in all_words
|
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 {
|
func (self *Completions) add_match_group(title string) *MatchGroup {
|
||||||
for _, q := range self.Groups {
|
for _, q := range self.Groups {
|
||||||
if q.Title == title {
|
if q.Title == title {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user