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:
parent
5c9afa5f78
commit
9cb4205b1d
@ -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
|
||||
|
7
pkg/interp/testdata/repl.fqtest
vendored
7
pkg/interp/testdata/repl.fqtest
vendored
@ -4,10 +4,13 @@ null> .
|
||||
null
|
||||
null> 1+1
|
||||
2
|
||||
null> (
|
||||
^ unexpected token <EOF>
|
||||
null> repl({color: true})
|
||||
[90m>[39m [37mnull[39m> )
|
||||
^ unexpected token ")"
|
||||
[90m>[39m [37mnull[39m> ^D
|
||||
null> )
|
||||
^ unexpected token ")"
|
||||
null>
|
||||
null> abc
|
||||
error: expr: function not defined: abc/0
|
||||
null> 1+"a"
|
||||
|
Loading…
Reference in New Issue
Block a user