mirror of https://github.com/Hilbis/Hilbish
fix: dont make continue prompt input include a newline
parent
050165d7b1
commit
7b0b06d9bf
4
main.go
4
main.go
|
@ -15,7 +15,7 @@ import (
|
||||||
"golang.org/x/term"
|
"golang.org/x/term"
|
||||||
)
|
)
|
||||||
|
|
||||||
const version = "0.4.0-dev.1+hilbiline"
|
const version = "0.4.0-dev.2+hilbiline"
|
||||||
var l *lua.LState
|
var l *lua.LState
|
||||||
// User's prompt, this will get set when lua side is initialized
|
// User's prompt, this will get set when lua side is initialized
|
||||||
var prompt string
|
var prompt string
|
||||||
|
@ -146,7 +146,7 @@ func ContinuePrompt(prev string) (string, error) {
|
||||||
}
|
}
|
||||||
cont = strings.TrimSpace(cont)
|
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)
|
// This semi cursed function formats our prompt (obviously)
|
||||||
|
|
3
shell.go
3
shell.go
|
@ -159,13 +159,14 @@ func HandleHistory(cmd string) {
|
||||||
func StartMultiline(prev string, sb *strings.Builder) bool {
|
func StartMultiline(prev string, sb *strings.Builder) bool {
|
||||||
// sb fromt outside is passed so we can
|
// sb fromt outside is passed so we can
|
||||||
// save input from previous prompts
|
// save input from previous prompts
|
||||||
if sb.String() == "" { sb.WriteString(prev + "\n") }
|
if sb.String() == "" { sb.WriteString(prev + " ") }
|
||||||
|
|
||||||
fmt.Print(multilinePrompt)
|
fmt.Print(multilinePrompt)
|
||||||
|
|
||||||
reader := bufio.NewReader(os.Stdin)
|
reader := bufio.NewReader(os.Stdin)
|
||||||
|
|
||||||
cont, err := reader.ReadString('\n')
|
cont, err := reader.ReadString('\n')
|
||||||
|
cont = strings.TrimSuffix(cont, "\n") + " "
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
// Exit when ^D
|
// Exit when ^D
|
||||||
fmt.Println("")
|
fmt.Println("")
|
||||||
|
|
Loading…
Reference in New Issue