mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-14 02:57:52 +08:00
cliedit: Fix crash when edit:listing:start-custom gets no &accept option.
This commit is contained in:
parent
edc0e98805
commit
9b4add3b4e
|
@ -98,7 +98,9 @@ func listingStartCustom(app cli.App, fm *eval.Frame, opts customListingOpts, ite
|
|||
return items, selected
|
||||
},
|
||||
Accept: func(s string) bool {
|
||||
callWithNotifyPorts(app, fm.Evaler, opts.Accept, s)
|
||||
if opts.Accept != nil {
|
||||
callWithNotifyPorts(app, fm.Evaler, opts.Accept, s)
|
||||
}
|
||||
return false
|
||||
},
|
||||
AutoAccept: opts.AutoAccept,
|
||||
|
|
|
@ -114,7 +114,7 @@ func TestCustomListing_PassingValueCallback(t *testing.T) {
|
|||
|
||||
evals(f.Evaler,
|
||||
`f = [q]{ put [&to-accept='q '$q &to-show=(styled 'q '$q blue)] }`,
|
||||
`edit:listing:start-custom $f &accept=$edit:insert-at-dot~ &caption=A`)
|
||||
`edit:listing:start-custom $f &caption=A`)
|
||||
// Query.
|
||||
f.TTYCtrl.Inject(term.K('x'))
|
||||
f.TestTTY(t,
|
||||
|
@ -124,6 +124,9 @@ func TestCustomListing_PassingValueCallback(t *testing.T) {
|
|||
"q x ", Styles,
|
||||
"##################################################",
|
||||
)
|
||||
// No-op accept.
|
||||
f.TTYCtrl.Inject(term.K('\n'))
|
||||
f.TestTTY(t, "~> ", term.DotHere)
|
||||
}
|
||||
|
||||
func TestCustomListing_PassingBytesCallback(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user