diff options
| author | Eyal Posener <[email protected]> | 2019-07-05 14:58:49 +0300 |
|---|---|---|
| committer | Eyal Posener <[email protected]> | 2019-07-05 17:29:25 +0300 |
| commit | 29f43e246ec41ee311a0a9bc24b15cb4ece4e513 (patch) | |
| tree | a89a2f4ae80897cb9a1f5f98f702ca2d8210731c /match | |
| parent | f71e6baaf2e0d387a847f8e599af7d75be650283 (diff) | |
deprecate match package
Diffstat (limited to 'match')
| -rw-r--r-- | match/file.go | 19 | ||||
| -rw-r--r-- | match/match.go | 32 | ||||
| -rw-r--r-- | match/prefix.go | 9 |
3 files changed, 32 insertions, 28 deletions
diff --git a/match/file.go b/match/file.go deleted file mode 100644 index 051171e..0000000 --- a/match/file.go +++ /dev/null @@ -1,19 +0,0 @@ -package match - -import "strings" - -// File returns true if prefix can match the file -func File(file, prefix string) bool { - // special case for current directory completion - if file == "./" && (prefix == "." || prefix == "") { - return true - } - if prefix == "." && strings.HasPrefix(file, ".") { - return true - } - - file = strings.TrimPrefix(file, "./") - prefix = strings.TrimPrefix(prefix, "./") - - return strings.HasPrefix(file, prefix) -} diff --git a/match/match.go b/match/match.go index b9c0973..b5f1814 100644 --- a/match/match.go +++ b/match/match.go @@ -1,7 +1,39 @@ // Package match contains matchers that decide if to apply completion. +// +// This package is deprecated. package match +import "strings" + // Match matches two strings // it is used for comparing a term to the last typed // word, the prefix, and see if it is a possible auto complete option. +// +// Deprecated. type Match func(term, prefix string) bool + +// Prefix is a simple Matcher, if the word is it's prefix, there is a match +// Match returns true if a has the prefix as prefix +// +// Deprecated. +func Prefix(long, prefix string) bool { + return strings.HasPrefix(long, prefix) +} + +// File returns true if prefix can match the file +// +// Deprecated. +func File(file, prefix string) bool { + // special case for current directory completion + if file == "./" && (prefix == "." || prefix == "") { + return true + } + if prefix == "." && strings.HasPrefix(file, ".") { + return true + } + + file = strings.TrimPrefix(file, "./") + prefix = strings.TrimPrefix(prefix, "./") + + return strings.HasPrefix(file, prefix) +} diff --git a/match/prefix.go b/match/prefix.go deleted file mode 100644 index 9a01ba6..0000000 --- a/match/prefix.go +++ /dev/null @@ -1,9 +0,0 @@ -package match - -import "strings" - -// Prefix is a simple Matcher, if the word is it's prefix, there is a match -// Match returns true if a has the prefix as prefix -func Prefix(long, prefix string) bool { - return strings.HasPrefix(long, prefix) -} |
