diff --git a/cli/chat.go b/cli/chat.go index f151934..739adb8 100644 --- a/cli/chat.go +++ b/cli/chat.go @@ -68,7 +68,7 @@ func (c *Chat) read() (string, bool) { func (c *Chat) readLine() (string, bool) { input, err := c.reader.Readline() if err != nil { - return c.handleReadError(err) + return c.handleReadError(input, err) } return validateInput(input) } @@ -79,7 +79,7 @@ func (c *Chat) readMultiLine() (string, bool) { for { input, err := c.reader.Readline() if err != nil { - return c.handleReadError(err) + return c.handleReadError(input, err) } if strings.HasSuffix(input, term) { builder.WriteString(strings.TrimSuffix(input, term)) @@ -101,9 +101,12 @@ func (c *Chat) parseCommand(message string) command { return newGeminiCommand(c) } -func (c *Chat) handleReadError(err error) (string, bool) { +func (c *Chat) handleReadError(input string, err error) (string, bool) { if errors.Is(err, readline.ErrInterrupt) { - return systemCmdQuit, true + if len(input) == 0 { + return systemCmdQuit, true + } + return "", false } fmt.Printf("%s%s\n", c.prompt.cli, err) return "", false