Fix empty ListMultiple.
This commit is contained in:
parent
e54d4e9414
commit
317cca7fc8
5 changed files with 15 additions and 7 deletions
|
@ -474,8 +474,10 @@ func lstResult(l []string, err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errResult(err)
|
errResult(err)
|
||||||
}
|
}
|
||||||
os.Stdout.WriteString(strings.Join(l, zenutil.Separator))
|
if len(l) > 0 {
|
||||||
os.Stdout.WriteString(zenutil.LineBreak)
|
os.Stdout.WriteString(strings.Join(l, zenutil.Separator))
|
||||||
|
os.Stdout.WriteString(zenutil.LineBreak)
|
||||||
|
}
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ if(Array.isArray(res)){res.join({{json .Separator}})}else{res.toString()}
|
||||||
var app=Application.currentApplication()
|
var app=Application.currentApplication()
|
||||||
app.includeStandardAdditions=true
|
app.includeStandardAdditions=true
|
||||||
var res=app.chooseFromList({{json .Items}},{{json .Options}})
|
var res=app.chooseFromList({{json .Items}},{{json .Options}})
|
||||||
res.join({{json .Separator}})
|
if(res.length!==0)res.join({{json .Separator}})
|
||||||
{{- end}}
|
{{- end}}
|
||||||
{{define "notify" -}}
|
{{define "notify" -}}
|
||||||
var app=Application.currentApplication()
|
var app=Application.currentApplication()
|
||||||
|
|
|
@ -2,4 +2,4 @@ var app = Application.currentApplication()
|
||||||
app.includeStandardAdditions = true
|
app.includeStandardAdditions = true
|
||||||
|
|
||||||
var res = app.chooseFromList({{json .Items}}, {{json .Options}})
|
var res = app.chooseFromList({{json .Items}}, {{json .Options}})
|
||||||
res.join({{json .Separator}})
|
if (res.length !== 0) res.join({{json .Separator}})
|
|
@ -71,8 +71,11 @@ func strResult(opts options, out []byte, err error) (string, error) {
|
||||||
|
|
||||||
func lstResult(opts options, out []byte, err error) ([]string, error) {
|
func lstResult(opts options, out []byte, err error) ([]string, error) {
|
||||||
str, err := strResult(opts, out, err)
|
str, err := strResult(opts, out, err)
|
||||||
if err == nil {
|
if err != nil {
|
||||||
return strings.Split(str, zenutil.Separator), nil
|
return nil, err
|
||||||
}
|
}
|
||||||
return nil, err
|
if len(out) == 0 {
|
||||||
|
return []string{}, nil
|
||||||
|
}
|
||||||
|
return strings.Split(str, zenutil.Separator), nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,6 +98,9 @@ func Test_lstResult(t *testing.T) {
|
||||||
sentinel := errors.New("sentinel")
|
sentinel := errors.New("sentinel")
|
||||||
cancel := exec.Command("false").Run()
|
cancel := exec.Command("false").Run()
|
||||||
|
|
||||||
|
if out, err := lstResult(options{}, []byte(""), nil); !reflect.DeepEqual(out, []string{}) || err != nil {
|
||||||
|
t.Errorf(`lstResult("out", nil) = %v, %v`, out, err)
|
||||||
|
}
|
||||||
if out, err := lstResult(options{}, []byte("out"), nil); !reflect.DeepEqual(out, []string{"out"}) || err != nil {
|
if out, err := lstResult(options{}, []byte("out"), nil); !reflect.DeepEqual(out, []string{"out"}) || err != nil {
|
||||||
t.Errorf(`lstResult("out", nil) = %v, %v`, out, err)
|
t.Errorf(`lstResult("out", nil) = %v, %v`, out, err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue