1
1
Fork 0

Fixes an issue with seed content

This commit is contained in:
sloum 2021-04-03 22:56:58 -07:00
parent 0e5b1ba06b
commit 48bedb4e12
1 changed files with 2 additions and 11 deletions

View File

@ -71,7 +71,6 @@ func GetInput(prompt string, content string) string {
termios.SetCharMode()
cols, _ := termios.GetWindowSize()
b := buffer{make([]rune, 0, (len(content)+1)*2), 0, cols-len(prompt), 0, 0, prompt}
seeded := false
fmt.Print(prompt)
fmt.Print("\033[6n")
@ -85,6 +84,8 @@ func GetInput(prompt string, content string) string {
if err != nil && err.Error() == "response" {
b.cursorStart = int(ch)
b.maxWidth = cols - b.cursorStart
b.seedContent(content)
b.printBuf()
} else if err != nil {
continue
}
@ -97,16 +98,6 @@ func GetInput(prompt string, content string) string {
} else {
b.addChar(ch, true)
}
// Seeding the content needs to happen
// _after_ reading in the width from the [6n
// function call.
if !seeded {
b.seedContent(content)
b.printBuf()
seeded = true
}
}
return b.string()
}