mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-28 03:01:57 +02:00
More work on readline completion
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"kitty/tools/cli"
|
||||
"kitty/tools/utils"
|
||||
)
|
||||
|
||||
var _ = fmt.Print
|
||||
@@ -39,7 +40,11 @@ func (self *completion) current_match_text() string {
|
||||
for _, g := range self.results.Groups {
|
||||
for _, m := range g.Matches {
|
||||
if i == self.current_match {
|
||||
return m.Word
|
||||
t := m.Word
|
||||
if !g.NoTrailingSpace {
|
||||
t += " "
|
||||
}
|
||||
return t
|
||||
}
|
||||
i++
|
||||
}
|
||||
@@ -83,6 +88,19 @@ func (self *Readline) complete(forwards bool, repeat_count uint) bool {
|
||||
}
|
||||
ct := c.current.current_match_text()
|
||||
if ct != "" {
|
||||
before := c.current.before_cursor[:c.current.results.CurrentWordIdx] + ct
|
||||
after := c.current.after_cursor
|
||||
self.input_state.lines = utils.Splitlines(before)
|
||||
if len(self.input_state.lines) == 0 {
|
||||
self.input_state.lines = []string{""}
|
||||
}
|
||||
self.input_state.cursor.Y = len(self.input_state.lines) - 1
|
||||
self.input_state.cursor.X = len(self.input_state.lines[self.input_state.cursor.Y])
|
||||
al := utils.Splitlines(after)
|
||||
if len(al) > 0 {
|
||||
self.input_state.lines[self.input_state.cursor.Y] += al[0]
|
||||
self.input_state.lines = append(self.input_state.lines, al[1:]...)
|
||||
}
|
||||
}
|
||||
if repeat_count > 0 {
|
||||
self.complete(forwards, repeat_count)
|
||||
|
||||
Reference in New Issue
Block a user