1
1
mirror of https://github.com/wader/fq.git synced 2024-10-04 15:38:17 +03:00

repl: Fix completion of non-underscore extkeys

For example .size for binary
This commit is contained in:
Mattias Wadman 2022-02-11 18:30:15 +01:00
parent 97a6bf694b
commit bd9be2c533
2 changed files with 8 additions and 5 deletions

View File

@ -28,6 +28,8 @@ def _complete_keywords:
def _complete_scope:
[scope[], _complete_keywords[]];
def _complete_keys:
[keys[]?, _extkeys[]?];
# TODO: handle variables via ast walk?
# TODO: refactor this
@ -55,10 +57,7 @@ def _complete($line; $cursor_pos):
# TODO: move map/add logic to here?
| _query_completion(
if .type | . == "func" or . == "var" then "_complete_scope"
elif .type == "index" then
if (.prefix | startswith("_")) then "_extkeys"
else "keys"
end
elif .type == "index" then "_complete_keys"
else error("unreachable")
end
) as {$type, $query, $prefix}
@ -79,7 +78,7 @@ def _complete($line; $cursor_pos):
strings and
# TODO: var type really needed? just func?
(_is_ident or $type == "var") and
((_is_internal | not) or $prefix_is_internal or $type == "index") and
((_is_internal | not) or $prefix_is_internal) and
startswith($prefix)
)
)

View File

@ -56,4 +56,8 @@ mp3> .frames\t
frames[]
mp3> .frames[]\t
.
mp3> "abc" | tobitsrange.s\t
size
start
stop
mp3> ^D