fix: dont make continue prompt input include a newline

pull/38/head
sammy 2021-04-19 22:08:16 -04:00
parent 050165d7b1
commit 7b0b06d9bf
No known key found for this signature in database
GPG Key ID: 50EE40A2809851F5
2 changed files with 4 additions and 3 deletions

View File

@ -15,7 +15,7 @@ import (
"golang.org/x/term"
)
const version = "0.4.0-dev.1+hilbiline"
const version = "0.4.0-dev.2+hilbiline"
var l *lua.LState
// User's prompt, this will get set when lua side is initialized
var prompt string
@ -146,7 +146,7 @@ func ContinuePrompt(prev string) (string, error) {
}
cont = strings.TrimSpace(cont)
return prev + "\n" + strings.TrimSuffix(cont, "\n"), nil
return prev + " " + strings.TrimSuffix(cont, "\n"), nil
}
// This semi cursed function formats our prompt (obviously)

View File

@ -159,13 +159,14 @@ func HandleHistory(cmd string) {
func StartMultiline(prev string, sb *strings.Builder) bool {
// sb fromt outside is passed so we can
// save input from previous prompts
if sb.String() == "" { sb.WriteString(prev + "\n") }
if sb.String() == "" { sb.WriteString(prev + " ") }
fmt.Print(multilinePrompt)
reader := bufio.NewReader(os.Stdin)
cont, err := reader.ReadString('\n')
cont = strings.TrimSuffix(cont, "\n") + " "
if err == io.EOF {
// Exit when ^D
fmt.Println("")