From 2c28621c2228b30f2f27a60db1e9a30da3e4c16f Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 9 Apr 2018 23:59:37 +0200 Subject: [PATCH] io: change prompt after line continuation This ensures that line continuations inside of e.g. integer and float expressions properly show a line continuation prompt. Fixes #1992 --- src/io.c | 8 +++++++- tst/testinstall/linecontinuation.tst | 13 +++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/io.c b/src/io.c index dd9ac0742f..1ec98676bd 100644 --- a/src/io.c +++ b/src/io.c @@ -201,8 +201,14 @@ Char GET_NEXT_CHAR(void) while (*STATE(In) == '\\' || *STATE(In) == 0) { if (!*STATE(In)) GetLine(); - else if (STATE(In)[1] == '\n') + else if (STATE(In)[1] == '\n') { STATE(In) += 2; + // print only a partial prompt from now on + if (!SyQuiet) + STATE(Prompt) = "> "; + else + STATE(Prompt) = ""; + } else if (STATE(In)[1] == '\r') STATE(In) += (STATE(In)[2] == '\n') ? 3 : 2; else diff --git a/tst/testinstall/linecontinuation.tst b/tst/testinstall/linecontinuation.tst index ee4e62eaa6..651c687b0b 100644 --- a/tst/testinstall/linecontinuation.tst +++ b/tst/testinstall/linecontinuation.tst @@ -35,6 +35,19 @@ gap> {x.\ > ..}->x; function( x... ) ... end +# inside float expressions +gap> 1.2e\ +> 0; +1.2 +gap> 1.1\ +> ; +1.1 + +# inside integer expressions +gap> 12\ +> 3; +123 + # however, in comments, you cannot use line continuations: gap> # 1234\ gap> 5;