mirror of
https://github.com/wader/fq.git
synced 2024-12-26 15:02:28 +03:00
Merge pull request #145 from wader/interp-unbreak-options-complete
repl,interp: Make stdio work during completion
This commit is contained in:
commit
04ba899334
@ -560,12 +560,12 @@ func (i *Interp) makeStateFn(state *interface{}) func(c interface{}, a []interfa
|
||||
|
||||
func (i *Interp) makeStdioFn(name string, t Terminal) func(c interface{}, a []interface{}) gojq.Iter {
|
||||
return func(c interface{}, a []interface{}) gojq.Iter {
|
||||
if i.evalContext.isCompleting {
|
||||
return gojq.NewIter("")
|
||||
}
|
||||
|
||||
switch {
|
||||
case len(a) == 1:
|
||||
if i.evalContext.isCompleting {
|
||||
return gojq.NewIter("")
|
||||
}
|
||||
|
||||
r, ok := t.(io.Reader)
|
||||
if !ok {
|
||||
return gojq.NewIter(fmt.Errorf("%s is not readable", name))
|
||||
@ -596,6 +596,10 @@ func (i *Interp) makeStdioFn(name string, t Terminal) func(c interface{}, a []in
|
||||
"height": h,
|
||||
})
|
||||
default:
|
||||
if i.evalContext.isCompleting {
|
||||
return gojq.NewIter()
|
||||
}
|
||||
|
||||
w, ok := t.(io.Writer)
|
||||
if !ok {
|
||||
return gojq.NewIter(fmt.Errorf("%v: it not writeable", c))
|
||||
|
4
pkg/interp/testdata/completion.fqtest
vendored
4
pkg/interp/testdata/completion.fqtest
vendored
@ -60,4 +60,8 @@ mp3> "abc" | tobitsrange.s\t
|
||||
size
|
||||
start
|
||||
stop
|
||||
mp3> options.c\t
|
||||
color
|
||||
colors
|
||||
compact
|
||||
mp3> ^D
|
||||
|
Loading…
Reference in New Issue
Block a user