1
1
mirror of https://github.com/wader/fq.git synced 2024-12-23 13:22:58 +03:00

repl: Correct error arrow position in color mode

This commit is contained in:
Mattias Wadman 2022-03-03 21:23:31 +01:00
parent 5c9afa5f78
commit 9cb4205b1d
2 changed files with 7 additions and 4 deletions

View File

@ -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

View File

@ -4,10 +4,13 @@ null> .
null
null> 1+1
2
null> (
^ unexpected token <EOF>
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"