Skip to content

Commit 3e548e1

Browse files
committed
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
1 parent 29bb736 commit 3e548e1

2 files changed

Lines changed: 29 additions & 3 deletions

File tree

src/io.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,13 @@ Char GET_NEXT_CHAR(void)
220220
// if we see a backlash without a line terminator after it, stop
221221
break;
222222
}
223+
224+
// if we get here, we saw a line continuation; change the prompt to a
225+
// partial prompt from now on
226+
if (!SyQuiet)
227+
STATE(Prompt) = "> ";
228+
else
229+
STATE(Prompt) = "";
223230
}
224231

225232
return *STATE(In);

tst/testinstall/linecontinuation.tst

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,17 @@ gap> START_TEST("linecontinuation.tst");
88
gap> x:="foo\
99
> bar";
1010
"foobar"
11+
gap> "foo\
12+
> bar";
13+
"foobar"
1114

1215
# in triple quoted string
13-
gap> x:="""haha\
14-
> !""";
15-
"haha!"
16+
gap> x:="""foo\
17+
> bar""";
18+
"foobar"
19+
gap> """foo\
20+
> bar""";
21+
"foobar"
1622

1723
# break keywords and operators like :=, <=, >= etc. in the middle
1824
gap> 1 m\
@@ -35,6 +41,19 @@ gap> {x.\
3541
> ..}->x;
3642
function( x... ) ... end
3743

44+
# inside float expressions
45+
gap> 1.2e\
46+
> 0;
47+
1.2
48+
gap> 1.1\
49+
> ;
50+
1.1
51+
52+
# inside integer expressions
53+
gap> 12\
54+
> 3;
55+
123
56+
3857
# however, in comments, you cannot use line continuations:
3958
gap> # 1234\
4059
gap> 5;

0 commit comments

Comments
 (0)