Skip to content

Commit

Permalink
Adds possibility to edit multiline requests
Browse files Browse the repository at this point in the history
  • Loading branch information
ksysoev committed Oct 15, 2023
1 parent 15b0450 commit 90b6886
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions pkg/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,19 @@ func (c *CLI) requestMode(keyStream <-chan keyboard.KeyEvent) (string, error) {
}

if buffer[len(buffer)-1] == '\n' {
continue
buffer = buffer[:len(buffer)-1]
fmt.Print(LINE_UP)
startPrevLine := strings.LastIndex(buffer, "\n")
if startPrevLine == -1 {
startPrevLine = 0
} else {
startPrevLine++
}
fmt.Print(buffer[startPrevLine:])
} else {
fmt.Print("\b \b")
buffer = buffer[:len(buffer)-1]
}

fmt.Print("\b \b")
buffer = buffer[:len(buffer)-1]
continue
case keyboard.KeyArrowUp:
historyIndex++
Expand Down

0 comments on commit 90b6886

Please sign in to comment.