diff --git a/pkg/repl/commands.go b/pkg/repl/commands.go index 87cf571a..5e6f9547 100644 --- a/pkg/repl/commands.go +++ b/pkg/repl/commands.go @@ -62,7 +62,9 @@ func def(r *REPL, s *scan.Scanner) error { } func pop(r *REPL, _ *scan.Scanner) error { - r.Calc.Pop() + if r.quoteEnd == "" { + r.Calc.Pop() + } return nil } diff --git a/pkg/repl/repl.go b/pkg/repl/repl.go index 85e6562c..660c837f 100644 --- a/pkg/repl/repl.go +++ b/pkg/repl/repl.go @@ -176,7 +176,7 @@ func (r *REPL) saveHistory() { func (r *REPL) getPrompt() string { if r.quoteEnd != "" { - return "...>" + return fmt.Sprintf("... %s> ", r.quoteEnd) } return zc.ProgName + " > " } diff --git a/pkg/repl/repl_test.go b/pkg/repl/repl_test.go index 280c64cd..c3c1c5ab 100644 --- a/pkg/repl/repl_test.go +++ b/pkg/repl/repl_test.go @@ -70,6 +70,25 @@ func TestQuote(t *testing.T) { } } +func TestQuoteBlanks(t *testing.T) { + ansi.Enabled = false + c := calc.New() + repl := New(c) + + repl.Eval("quote EOF") + repl.Eval("1 2 add") + repl.Eval("2 3 sub") + repl.Eval("") + repl.Eval("") + repl.Eval("EOF") + + have := c.Stack() + want := []string{"1 2 add", "2 3 sub"} + if !reflect.DeepEqual(have, want) { + t.Fatalf("\n have: %v \n want: %v", have, want) + } +} + func TestCommonPrefix(t *testing.T) { tests := []struct { common string