diff --git a/pkg/interp/repl.jq b/pkg/interp/repl.jq index 35a63d36..30216bc3 100644 --- a/pkg/interp/repl.jq +++ b/pkg/interp/repl.jq @@ -175,7 +175,7 @@ def _prompt($opts): end; [ (_repl_level | _ansi_if($opts; "prompt_repl_level")) , _values ] | join(" ") + "> "; - +def _prompt: _prompt(null); # user expr error def _repl_on_expr_error: @@ -194,7 +194,7 @@ def _repl_on_compile_error: ( # TODO: move, redo as: def _symbols: if unicode then {...} else {...} end? def _arrow_up: if options.unicode then "⬆" else "^" end; if .error.column != 0 then - ( ((.input | _prompt(options) | length) + .error.column-1) as $pos + ( ((.input | _prompt | length) + .error.column-1) as $pos | " " * $pos + "\(_arrow_up) \(.error.error)" ) else diff --git a/pkg/interp/testdata/repl.fqtest b/pkg/interp/testdata/repl.fqtest index c0babaea..f50e1676 100644 --- a/pkg/interp/testdata/repl.fqtest +++ b/pkg/interp/testdata/repl.fqtest @@ -4,10 +4,13 @@ null> . null null> 1+1 2 -null> ( - ^ unexpected token +null> repl({color: true}) +> null> ) + ^ unexpected token ")" +> null> ^D null> ) ^ unexpected token ")" +null> null> abc error: expr: function not defined: abc/0 null> 1+"a"