Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

io: change prompt after line continuation #2350

Merged
merged 1 commit into from
Apr 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,13 @@ Char GET_NEXT_CHAR(void)
// if we see a backlash without a line terminator after it, stop
break;
}

// if we get here, we saw a line continuation; change the prompt to a
// partial prompt from now on
if (!SyQuiet)
STATE(Prompt) = "> ";
else
STATE(Prompt) = "";
}

return *STATE(In);
Expand Down
25 changes: 22 additions & 3 deletions tst/testinstall/linecontinuation.tst
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@ gap> START_TEST("linecontinuation.tst");
gap> x:="foo\
> bar";
"foobar"
gap> "foo\
> bar";
"foobar"

# in triple quoted string
gap> x:="""haha\
> !""";
"haha!"
gap> x:="""foo\
> bar""";
"foobar"
gap> """foo\
> bar""";
"foobar"

# break keywords and operators like :=, <=, >= etc. in the middle
gap> 1 m\
Expand All @@ -35,6 +41,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