Browse Source

Fix paste of text with line feed characters (#3043)

Some terminals may send line feed characters when pasting text with
newlines.
Giuseppe Lumia 1 năm trước cách đây
mục cha
commit
2a5302a1cf
1 tập tin đã thay đổi với 2 bổ sung2 xóa
  1. 2 2
      readline/readline.go

+ 2 - 2
readline/readline.go

@@ -218,7 +218,7 @@ func (i *Instance) Readline() (string, error) {
 		case CharCtrlZ:
 		case CharCtrlZ:
 			fd := int(syscall.Stdin)
 			fd := int(syscall.Stdin)
 			return handleCharCtrlZ(fd, i.Terminal.termios)
 			return handleCharCtrlZ(fd, i.Terminal.termios)
-		case CharEnter:
+		case CharEnter, CharCtrlJ:
 			output := buf.String()
 			output := buf.String()
 			if output != "" {
 			if output != "" {
 				i.History.Add([]rune(output))
 				i.History.Add([]rune(output))
@@ -232,7 +232,7 @@ func (i *Instance) Readline() (string, error) {
 				metaDel = false
 				metaDel = false
 				continue
 				continue
 			}
 			}
-			if r >= CharSpace || r == CharEnter {
+			if r >= CharSpace || r == CharEnter || r == CharCtrlJ {
 				buf.Add(r)
 				buf.Add(r)
 			}
 			}
 		}
 		}