Browse Source

fix formatting when exiting `ollama run`

Jeffrey Morgan 1 year ago
parent
commit
9ec16f0f03
2 changed files with 5 additions and 3 deletions
  1. 1 0
      cmd/cmd.go
  2. 4 3
      readline/readline.go

+ 1 - 0
cmd/cmd.go

@@ -561,6 +561,7 @@ func generateInteractive(cmd *cobra.Command, model string) error {
 		line, err := scanner.Readline()
 		switch {
 		case errors.Is(err, io.EOF):
+			fmt.Println()
 			return nil
 		case errors.Is(err, readline.ErrInterrupt):
 			if line == "" {

+ 4 - 3
readline/readline.go

@@ -76,14 +76,15 @@ func (i *Instance) Readline() (string, error) {
 		}
 
 		r, err := i.Terminal.Read()
-		if err != nil {
-			return "", io.EOF
-		}
 
 		if buf.IsEmpty() {
 			fmt.Print(ClearToEOL)
 		}
 
+		if err != nil {
+			return "", io.EOF
+		}
+
 		if escex {
 			escex = false