mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-11-27 15:01:22 +08:00
pkg/edit: Fix crash in edit:complete-filename when given no arguments.
This fixes #1799.
This commit is contained in:
parent
1aeb2f6e98
commit
57078f79be
|
@ -22,6 +22,9 @@ var eachExternal = fsutil.EachExternal
|
|||
// GenerateFileNames returns filename candidates that are suitable for completing
|
||||
// the last argument. It can be used in Config.ArgGenerator.
|
||||
func GenerateFileNames(args []string) ([]RawItem, error) {
|
||||
if len(args) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
return generateFileNames(args[len(args)-1], false)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,16 @@
|
|||
//each:complex-candidate-in-global
|
||||
/////////////////////
|
||||
# complete-filename #
|
||||
/////////////////////
|
||||
//complete-filename-in-global
|
||||
// Don't crash with no argument. Regression test for b.elv.sh/1799.
|
||||
~> complete-filename
|
||||
|
||||
/////////////////////
|
||||
# complex-candidate #
|
||||
/////////////////////
|
||||
|
||||
//each:complex-candidate-in-global
|
||||
|
||||
## construction ##
|
||||
~> complex-candidate a/b
|
||||
▶ (edit:complex-candidate a/b &code-suffix='' &display=[^styled])
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"embed"
|
||||
"testing"
|
||||
|
||||
"src.elv.sh/pkg/edit/complete"
|
||||
"src.elv.sh/pkg/eval"
|
||||
"src.elv.sh/pkg/eval/evaltest"
|
||||
)
|
||||
|
@ -21,6 +22,8 @@ func TestTranscripts(t *testing.T) {
|
|||
"binding-map-in-global", fnInGlobal("binding-map", makeBindingMap),
|
||||
"wordify-in-global", fnInGlobal("wordify", wordify),
|
||||
"complete-getopt-in-global", fnInGlobal("complete-getopt", completeGetopt),
|
||||
"complete-filename-in-global", fnInGlobal("complete-filename",
|
||||
wrapArgGenerator(complete.GenerateFileNames)),
|
||||
"complex-candidate-in-global", fnInGlobal("complex-candidate", complexCandidate),
|
||||
"add-var-in-global", fnInGlobal("add-var", addVar),
|
||||
"add-vars-in-global", fnInGlobal("add-vars", addVars),
|
||||
|
|
Loading…
Reference in New Issue
Block a user