complete/match/file.go

17 lines
368 B
Go
Raw Normal View History

2017-05-07 11:53:55 -05:00
package match
2017-05-11 12:48:40 -05:00
import "strings"
2017-05-07 11:53:55 -05:00
2017-05-11 12:48:40 -05:00
// File returns true if prefix can match the file
func File(file, prefix string) bool {
// special case for current directory completion
2017-05-11 12:48:40 -05:00
if file == "./" && (prefix == "." || prefix == "") {
return true
2017-05-07 11:53:55 -05:00
}
2017-05-11 12:48:40 -05:00
file = strings.TrimPrefix(file, "./")
prefix = strings.TrimPrefix(prefix, "./")
2017-05-11 12:48:40 -05:00
return strings.HasPrefix(file, prefix)
2017-05-07 11:53:55 -05:00
}