Run goimports
This commit is contained in:
parent
66c8d4ca5c
commit
d916343aba
@ -24,7 +24,6 @@ func main() {
|
||||
pt := prompt.NewPrompt(
|
||||
executor,
|
||||
completer,
|
||||
prompt.OptionMaxCompletions(8),
|
||||
prompt.OptionPrefix(">>> "),
|
||||
prompt.OptionTitle("sqlite3-cli"),
|
||||
prompt.OptionOutputTextColor(prompt.DarkGray),
|
||||
|
@ -80,14 +80,14 @@ func (r *Render) renderCompletion(buf *Buffer, words []string, max uint16, selec
|
||||
|
||||
formatted, width := formatCompletions(
|
||||
words,
|
||||
int(r.col) - len(r.prefix),
|
||||
int(r.col)-len(r.prefix),
|
||||
" ",
|
||||
" ",
|
||||
)
|
||||
l := len(formatted)
|
||||
|
||||
d := (len(r.prefix) + len(buf.Document().TextBeforeCursor())) % int(r.col)
|
||||
if d + width > int(r.col) {
|
||||
if d+width > int(r.col) {
|
||||
r.out.CursorBackward(d + width - int(r.col))
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ func (r *Render) renderCompletion(buf *Buffer, words []string, max uint16, selec
|
||||
r.out.WriteStr(formatted[i])
|
||||
r.out.CursorBackward(width)
|
||||
}
|
||||
if d + width > int(r.col) {
|
||||
if d+width > int(r.col) {
|
||||
r.out.CursorForward(d + width - int(r.col))
|
||||
}
|
||||
|
||||
@ -172,15 +172,15 @@ func formatCompletions(words []string, max int, prefix string, suffix string) (n
|
||||
}
|
||||
}
|
||||
|
||||
if len(prefix) + width + len(suffix) > max {
|
||||
if len(prefix)+width+len(suffix) > max {
|
||||
width = max - len(prefix) - len(suffix)
|
||||
}
|
||||
|
||||
for i := 0; i < num; i++ {
|
||||
if l := len(words[i]); l > width {
|
||||
new[i] = prefix + words[i][:width - len("...")] + "..." + suffix
|
||||
new[i] = prefix + words[i][:width-len("...")] + "..." + suffix
|
||||
} else if l < width {
|
||||
spaces := strings.Repeat(" ", width - len([]rune(words[i])))
|
||||
spaces := strings.Repeat(" ", width-len([]rune(words[i])))
|
||||
new[i] = prefix + words[i] + spaces + suffix
|
||||
} else {
|
||||
new[i] = prefix + words[i] + suffix
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
func TestFormatCompletion(t *testing.T) {
|
||||
scenarioTable := [] struct {
|
||||
scenarioTable := []struct {
|
||||
scenario string
|
||||
completions []string
|
||||
prefix string
|
||||
@ -14,7 +14,7 @@ func TestFormatCompletion(t *testing.T) {
|
||||
expected []string
|
||||
maxWidth int
|
||||
expectedWidth int
|
||||
} {
|
||||
}{
|
||||
{
|
||||
scenario: "",
|
||||
completions: []string{
|
||||
|
Loading…
Reference in New Issue
Block a user