summaryrefslogtreecommitdiff
path: root/match/file.go
diff options
context:
space:
mode:
authorEyal Posener <[email protected]>2017-05-11 20:54:26 +0300
committerGitHub <[email protected]>2017-05-11 20:54:26 +0300
commitd3bbb859d52b45987e3cd2098e28423f32edd999 (patch)
tree4265893d0c665ba0e763482a70c9044fa983a1ed /match/file.go
parentdd2171d085ef5957a1c5c0794d6007822e47849b (diff)
parentba23c350c73d2dfdf071c14c22152bcaf7e7fd7b (diff)
Merge pull request #12 from posener/improves
Enhance program structure and data structures
Diffstat (limited to 'match/file.go')
-rw-r--r--match/file.go22
1 files changed, 6 insertions, 16 deletions
diff --git a/match/file.go b/match/file.go
index 0b554ce..eee5bec 100644
--- a/match/file.go
+++ b/match/file.go
@@ -1,26 +1,16 @@
package match
-import (
- "strings"
-)
+import "strings"
-// File is a file name Matcher, if the last word can prefix the
-// File path, there is a possible match
-type File string
-
-func (a File) String() string {
- return string(a)
-}
-
-// Match returns true if prefix's abs path prefixes a's abs path
-func (a File) Match(prefix string) bool {
+// File returns true if prefix can match the file
+func File(file, prefix string) bool {
// special case for current directory completion
- if a == "./" && (prefix == "." || prefix == "") {
+ if file == "./" && (prefix == "." || prefix == "") {
return true
}
- cmp := strings.TrimPrefix(string(a), "./")
+ file = strings.TrimPrefix(file, "./")
prefix = strings.TrimPrefix(prefix, "./")
- return strings.HasPrefix(cmp, prefix)
+ return strings.HasPrefix(file, prefix)
}