Skip to content

Commit

Permalink
io: change prompt after line continuation
Browse files Browse the repository at this point in the history
This ensures that line continuations inside of e.g. integer and float
expressions properly show a line continuation prompt.

Fixes #1992
  • Loading branch information
fingolfin committed Apr 10, 2018
1 parent 9c704a9 commit 2c28621
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions tst/testinstall/linecontinuation.tst
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2c28621

Please sign in to comment.