Skip to content

Commit e086922

Browse files
fix: if mid-word then provide all possible completions
1 parent 5e10c13 commit e086922

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

complete.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ func (o *opCompleter) CompleteRefresh() {
214214
if inSelect {
215215
buf.WriteString("\033[30;47m")
216216
}
217-
buf.WriteString(string(same))
218217
buf.WriteString(string(c))
219218
buf.WriteString("\n")
220219

completers/complete_long_short.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,15 @@ func doLongShortInternal(p LongShortCompleter, line []rune, pos int, origLine []
8585
newLine = append(newLine, []rune{' '})
8686
}
8787
} else {
88-
newLine = append(newLine, []rune(fmt.Sprintf("%s\t%s", childName, string(child.Text))))
88+
if long {
89+
newLine = append(newLine, []rune(fmt.Sprintf("%s\t\t%s", childName, string(child.Text))))
90+
} else {
91+
if newLine == nil {
92+
newLine = [][]rune{[]rune(childName)}
93+
} else {
94+
newLine[0] = []rune(fmt.Sprintf("%s\t%s", string(newLine[0]), childName))
95+
}
96+
}
8997
}
9098
offset = len(childName)
9199
lineCompleter = child
@@ -95,8 +103,15 @@ func doLongShortInternal(p LongShortCompleter, line []rune, pos int, origLine []
95103
// check if whole line matches a child
96104
if runes.HasPrefix([]rune(childName), line) {
97105
// the entire line already matches a child
98-
// newLine = append(newLine, []rune(childName[len(line):]))
99-
newLine = append(newLine, []rune(fmt.Sprintf("%s\t\t%s", childName[len(line):], string(child.Text))))
106+
if long {
107+
newLine = append(newLine, []rune(fmt.Sprintf("%s\t\t%s", childName[len(line):], string(child.Text))))
108+
} else {
109+
if newLine == nil {
110+
newLine = [][]rune{[]rune(childName)}
111+
} else {
112+
newLine[0] = []rune(fmt.Sprintf("%s\t%s", string(newLine[0]), childName))
113+
}
114+
}
100115

101116
offset = len(line)
102117
lineCompleter = child

0 commit comments

Comments
 (0)