Support escaping carriage returns with \ (#1127)
This commit is contained in:
parent
e59c872b3d
commit
708ba8902a
|
@ -283,8 +283,15 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
|
||||||
|
|
||||||
// Ctrl+Enter for newline, Enter for submit
|
// Ctrl+Enter for newline, Enter for submit
|
||||||
if (key.return) {
|
if (key.return) {
|
||||||
if (key.ctrl) {
|
const [row, col] = buffer.cursor;
|
||||||
// Ctrl+Enter for newline
|
const line = buffer.lines[row];
|
||||||
|
const charBefore = col > 0 ? cpSlice(line, col - 1, col) : '';
|
||||||
|
|
||||||
|
if (key.ctrl || charBefore === '\\') {
|
||||||
|
// Ctrl+Enter or escaped newline
|
||||||
|
if (charBefore === '\\') {
|
||||||
|
buffer.backspace();
|
||||||
|
}
|
||||||
buffer.newline();
|
buffer.newline();
|
||||||
} else {
|
} else {
|
||||||
// Enter for submit
|
// Enter for submit
|
||||||
|
|
Loading…
Reference in New Issue