diff --git a/cliedit/listing_custom.go b/cliedit/listing_custom.go index 2ef7ea11..258339f9 100644 --- a/cliedit/listing_custom.go +++ b/cliedit/listing_custom.go @@ -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, diff --git a/cliedit/listing_test.go b/cliedit/listing_test.go index c544421c..5f11e5f2 100644 --- a/cliedit/listing_test.go +++ b/cliedit/listing_test.go @@ -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) {