doing 2.0.20 → 2.0.24

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/Gemfile.lock +1 -1
  4. data/README.md +1 -1
  5. data/doing.rdoc +1 -1
  6. data/lib/doing/log_adapter.rb +3 -1
  7. data/lib/doing/version.rb +1 -1
  8. data/lib/doing/wwid.rb +19 -8
  9. data/lib/helpers/fzf/.goreleaser.yml +119 -0
  10. data/lib/helpers/fzf/.rubocop.yml +28 -0
  11. data/lib/helpers/fzf/ADVANCED.md +565 -0
  12. data/lib/helpers/fzf/BUILD.md +49 -0
  13. data/lib/helpers/fzf/CHANGELOG.md +1193 -0
  14. data/lib/helpers/fzf/Dockerfile +11 -0
  15. data/lib/helpers/fzf/LICENSE +21 -0
  16. data/lib/helpers/fzf/Makefile +166 -0
  17. data/lib/helpers/fzf/README-VIM.md +486 -0
  18. data/lib/helpers/fzf/README.md +712 -0
  19. data/lib/helpers/fzf/bin/fzf-tmux +233 -0
  20. data/lib/helpers/fzf/doc/fzf.txt +512 -0
  21. data/lib/helpers/fzf/go.mod +17 -0
  22. data/lib/helpers/fzf/go.sum +31 -0
  23. data/lib/helpers/fzf/install +382 -0
  24. data/lib/helpers/fzf/install.ps1 +65 -0
  25. data/lib/helpers/fzf/main.go +14 -0
  26. data/lib/helpers/fzf/man/man1/fzf-tmux.1 +68 -0
  27. data/lib/helpers/fzf/man/man1/fzf.1 +1001 -0
  28. data/lib/helpers/fzf/plugin/fzf.vim +1048 -0
  29. data/lib/helpers/fzf/shell/completion.bash +381 -0
  30. data/lib/helpers/fzf/shell/completion.zsh +329 -0
  31. data/lib/helpers/fzf/shell/key-bindings.bash +96 -0
  32. data/lib/helpers/fzf/shell/key-bindings.fish +172 -0
  33. data/lib/helpers/fzf/shell/key-bindings.zsh +114 -0
  34. data/lib/helpers/fzf/src/LICENSE +21 -0
  35. data/lib/helpers/fzf/src/algo/algo.go +884 -0
  36. data/lib/helpers/fzf/src/algo/algo_test.go +197 -0
  37. data/lib/helpers/fzf/src/algo/normalize.go +492 -0
  38. data/lib/helpers/fzf/src/ansi.go +409 -0
  39. data/lib/helpers/fzf/src/ansi_test.go +427 -0
  40. data/lib/helpers/fzf/src/cache.go +81 -0
  41. data/lib/helpers/fzf/src/cache_test.go +39 -0
  42. data/lib/helpers/fzf/src/chunklist.go +89 -0
  43. data/lib/helpers/fzf/src/chunklist_test.go +80 -0
  44. data/lib/helpers/fzf/src/constants.go +85 -0
  45. data/lib/helpers/fzf/src/core.go +351 -0
  46. data/lib/helpers/fzf/src/history.go +96 -0
  47. data/lib/helpers/fzf/src/history_test.go +68 -0
  48. data/lib/helpers/fzf/src/item.go +44 -0
  49. data/lib/helpers/fzf/src/item_test.go +23 -0
  50. data/lib/helpers/fzf/src/matcher.go +235 -0
  51. data/lib/helpers/fzf/src/merger.go +120 -0
  52. data/lib/helpers/fzf/src/merger_test.go +88 -0
  53. data/lib/helpers/fzf/src/options.go +1691 -0
  54. data/lib/helpers/fzf/src/options_test.go +457 -0
  55. data/lib/helpers/fzf/src/pattern.go +425 -0
  56. data/lib/helpers/fzf/src/pattern_test.go +209 -0
  57. data/lib/helpers/fzf/src/protector/protector.go +8 -0
  58. data/lib/helpers/fzf/src/protector/protector_openbsd.go +10 -0
  59. data/lib/helpers/fzf/src/reader.go +201 -0
  60. data/lib/helpers/fzf/src/reader_test.go +63 -0
  61. data/lib/helpers/fzf/src/result.go +243 -0
  62. data/lib/helpers/fzf/src/result_others.go +16 -0
  63. data/lib/helpers/fzf/src/result_test.go +159 -0
  64. data/lib/helpers/fzf/src/result_x86.go +16 -0
  65. data/lib/helpers/fzf/src/terminal.go +2832 -0
  66. data/lib/helpers/fzf/src/terminal_test.go +638 -0
  67. data/lib/helpers/fzf/src/terminal_unix.go +26 -0
  68. data/lib/helpers/fzf/src/terminal_windows.go +45 -0
  69. data/lib/helpers/fzf/src/tokenizer.go +253 -0
  70. data/lib/helpers/fzf/src/tokenizer_test.go +112 -0
  71. data/lib/helpers/fzf/src/tui/dummy.go +46 -0
  72. data/lib/helpers/fzf/src/tui/light.go +987 -0
  73. data/lib/helpers/fzf/src/tui/light_unix.go +110 -0
  74. data/lib/helpers/fzf/src/tui/light_windows.go +145 -0
  75. data/lib/helpers/fzf/src/tui/tcell.go +721 -0
  76. data/lib/helpers/fzf/src/tui/tcell_test.go +392 -0
  77. data/lib/helpers/fzf/src/tui/ttyname_unix.go +47 -0
  78. data/lib/helpers/fzf/src/tui/ttyname_windows.go +14 -0
  79. data/lib/helpers/fzf/src/tui/tui.go +625 -0
  80. data/lib/helpers/fzf/src/tui/tui_test.go +20 -0
  81. data/lib/helpers/fzf/src/util/atomicbool.go +34 -0
  82. data/lib/helpers/fzf/src/util/atomicbool_test.go +17 -0
  83. data/lib/helpers/fzf/src/util/chars.go +198 -0
  84. data/lib/helpers/fzf/src/util/chars_test.go +46 -0
  85. data/lib/helpers/fzf/src/util/eventbox.go +96 -0
  86. data/lib/helpers/fzf/src/util/eventbox_test.go +61 -0
  87. data/lib/helpers/fzf/src/util/slab.go +12 -0
  88. data/lib/helpers/fzf/src/util/util.go +138 -0
  89. data/lib/helpers/fzf/src/util/util_test.go +40 -0
  90. data/lib/helpers/fzf/src/util/util_unix.go +47 -0
  91. data/lib/helpers/fzf/src/util/util_windows.go +83 -0
  92. data/lib/helpers/fzf/test/fzf.vader +175 -0
  93. data/lib/helpers/fzf/test/test_go.rb +2626 -0
  94. data/lib/helpers/fzf/uninstall +117 -0
  95. metadata +88 -2
@@ -0,0 +1,197 @@
1
+ package algo
2
+
3
+ import (
4
+ "math"
5
+ "sort"
6
+ "strings"
7
+ "testing"
8
+
9
+ "github.com/junegunn/fzf/src/util"
10
+ )
11
+
12
+ func assertMatch(t *testing.T, fun Algo, caseSensitive, forward bool, input, pattern string, sidx int, eidx int, score int) {
13
+ assertMatch2(t, fun, caseSensitive, false, forward, input, pattern, sidx, eidx, score)
14
+ }
15
+
16
+ func assertMatch2(t *testing.T, fun Algo, caseSensitive, normalize, forward bool, input, pattern string, sidx int, eidx int, score int) {
17
+ if !caseSensitive {
18
+ pattern = strings.ToLower(pattern)
19
+ }
20
+ chars := util.ToChars([]byte(input))
21
+ res, pos := fun(caseSensitive, normalize, forward, &chars, []rune(pattern), true, nil)
22
+ var start, end int
23
+ if pos == nil || len(*pos) == 0 {
24
+ start = res.Start
25
+ end = res.End
26
+ } else {
27
+ sort.Ints(*pos)
28
+ start = (*pos)[0]
29
+ end = (*pos)[len(*pos)-1] + 1
30
+ }
31
+ if start != sidx {
32
+ t.Errorf("Invalid start index: %d (expected: %d, %s / %s)", start, sidx, input, pattern)
33
+ }
34
+ if end != eidx {
35
+ t.Errorf("Invalid end index: %d (expected: %d, %s / %s)", end, eidx, input, pattern)
36
+ }
37
+ if res.Score != score {
38
+ t.Errorf("Invalid score: %d (expected: %d, %s / %s)", res.Score, score, input, pattern)
39
+ }
40
+ }
41
+
42
+ func TestFuzzyMatch(t *testing.T) {
43
+ for _, fn := range []Algo{FuzzyMatchV1, FuzzyMatchV2} {
44
+ for _, forward := range []bool{true, false} {
45
+ assertMatch(t, fn, false, forward, "fooBarbaz1", "oBZ", 2, 9,
46
+ scoreMatch*3+bonusCamel123+scoreGapStart+scoreGapExtension*3)
47
+ assertMatch(t, fn, false, forward, "foo bar baz", "fbb", 0, 9,
48
+ scoreMatch*3+bonusBoundary*bonusFirstCharMultiplier+
49
+ bonusBoundary*2+2*scoreGapStart+4*scoreGapExtension)
50
+ assertMatch(t, fn, false, forward, "/AutomatorDocument.icns", "rdoc", 9, 13,
51
+ scoreMatch*4+bonusCamel123+bonusConsecutive*2)
52
+ assertMatch(t, fn, false, forward, "/man1/zshcompctl.1", "zshc", 6, 10,
53
+ scoreMatch*4+bonusBoundary*bonusFirstCharMultiplier+bonusBoundary*3)
54
+ assertMatch(t, fn, false, forward, "/.oh-my-zsh/cache", "zshc", 8, 13,
55
+ scoreMatch*4+bonusBoundary*bonusFirstCharMultiplier+bonusBoundary*3+scoreGapStart)
56
+ assertMatch(t, fn, false, forward, "ab0123 456", "12356", 3, 10,
57
+ scoreMatch*5+bonusConsecutive*3+scoreGapStart+scoreGapExtension)
58
+ assertMatch(t, fn, false, forward, "abc123 456", "12356", 3, 10,
59
+ scoreMatch*5+bonusCamel123*bonusFirstCharMultiplier+bonusCamel123*2+bonusConsecutive+scoreGapStart+scoreGapExtension)
60
+ assertMatch(t, fn, false, forward, "foo/bar/baz", "fbb", 0, 9,
61
+ scoreMatch*3+bonusBoundary*bonusFirstCharMultiplier+
62
+ bonusBoundary*2+2*scoreGapStart+4*scoreGapExtension)
63
+ assertMatch(t, fn, false, forward, "fooBarBaz", "fbb", 0, 7,
64
+ scoreMatch*3+bonusBoundary*bonusFirstCharMultiplier+
65
+ bonusCamel123*2+2*scoreGapStart+2*scoreGapExtension)
66
+ assertMatch(t, fn, false, forward, "foo barbaz", "fbb", 0, 8,
67
+ scoreMatch*3+bonusBoundary*bonusFirstCharMultiplier+bonusBoundary+
68
+ scoreGapStart*2+scoreGapExtension*3)
69
+ assertMatch(t, fn, false, forward, "fooBar Baz", "foob", 0, 4,
70
+ scoreMatch*4+bonusBoundary*bonusFirstCharMultiplier+bonusBoundary*3)
71
+ assertMatch(t, fn, false, forward, "xFoo-Bar Baz", "foo-b", 1, 6,
72
+ scoreMatch*5+bonusCamel123*bonusFirstCharMultiplier+bonusCamel123*2+
73
+ bonusNonWord+bonusBoundary)
74
+
75
+ assertMatch(t, fn, true, forward, "fooBarbaz", "oBz", 2, 9,
76
+ scoreMatch*3+bonusCamel123+scoreGapStart+scoreGapExtension*3)
77
+ assertMatch(t, fn, true, forward, "Foo/Bar/Baz", "FBB", 0, 9,
78
+ scoreMatch*3+bonusBoundary*(bonusFirstCharMultiplier+2)+
79
+ scoreGapStart*2+scoreGapExtension*4)
80
+ assertMatch(t, fn, true, forward, "FooBarBaz", "FBB", 0, 7,
81
+ scoreMatch*3+bonusBoundary*bonusFirstCharMultiplier+bonusCamel123*2+
82
+ scoreGapStart*2+scoreGapExtension*2)
83
+ assertMatch(t, fn, true, forward, "FooBar Baz", "FooB", 0, 4,
84
+ scoreMatch*4+bonusBoundary*bonusFirstCharMultiplier+bonusBoundary*2+
85
+ util.Max(bonusCamel123, bonusBoundary))
86
+
87
+ // Consecutive bonus updated
88
+ assertMatch(t, fn, true, forward, "foo-bar", "o-ba", 2, 6,
89
+ scoreMatch*4+bonusBoundary*3)
90
+
91
+ // Non-match
92
+ assertMatch(t, fn, true, forward, "fooBarbaz", "oBZ", -1, -1, 0)
93
+ assertMatch(t, fn, true, forward, "Foo Bar Baz", "fbb", -1, -1, 0)
94
+ assertMatch(t, fn, true, forward, "fooBarbaz", "fooBarbazz", -1, -1, 0)
95
+ }
96
+ }
97
+ }
98
+
99
+ func TestFuzzyMatchBackward(t *testing.T) {
100
+ assertMatch(t, FuzzyMatchV1, false, true, "foobar fb", "fb", 0, 4,
101
+ scoreMatch*2+bonusBoundary*bonusFirstCharMultiplier+
102
+ scoreGapStart+scoreGapExtension)
103
+ assertMatch(t, FuzzyMatchV1, false, false, "foobar fb", "fb", 7, 9,
104
+ scoreMatch*2+bonusBoundary*bonusFirstCharMultiplier+bonusBoundary)
105
+ }
106
+
107
+ func TestExactMatchNaive(t *testing.T) {
108
+ for _, dir := range []bool{true, false} {
109
+ assertMatch(t, ExactMatchNaive, true, dir, "fooBarbaz", "oBA", -1, -1, 0)
110
+ assertMatch(t, ExactMatchNaive, true, dir, "fooBarbaz", "fooBarbazz", -1, -1, 0)
111
+
112
+ assertMatch(t, ExactMatchNaive, false, dir, "fooBarbaz", "oBA", 2, 5,
113
+ scoreMatch*3+bonusCamel123+bonusConsecutive)
114
+ assertMatch(t, ExactMatchNaive, false, dir, "/AutomatorDocument.icns", "rdoc", 9, 13,
115
+ scoreMatch*4+bonusCamel123+bonusConsecutive*2)
116
+ assertMatch(t, ExactMatchNaive, false, dir, "/man1/zshcompctl.1", "zshc", 6, 10,
117
+ scoreMatch*4+bonusBoundary*(bonusFirstCharMultiplier+3))
118
+ assertMatch(t, ExactMatchNaive, false, dir, "/.oh-my-zsh/cache", "zsh/c", 8, 13,
119
+ scoreMatch*5+bonusBoundary*(bonusFirstCharMultiplier+4))
120
+ }
121
+ }
122
+
123
+ func TestExactMatchNaiveBackward(t *testing.T) {
124
+ assertMatch(t, ExactMatchNaive, false, true, "foobar foob", "oo", 1, 3,
125
+ scoreMatch*2+bonusConsecutive)
126
+ assertMatch(t, ExactMatchNaive, false, false, "foobar foob", "oo", 8, 10,
127
+ scoreMatch*2+bonusConsecutive)
128
+ }
129
+
130
+ func TestPrefixMatch(t *testing.T) {
131
+ score := (scoreMatch+bonusBoundary)*3 + bonusBoundary*(bonusFirstCharMultiplier-1)
132
+
133
+ for _, dir := range []bool{true, false} {
134
+ assertMatch(t, PrefixMatch, true, dir, "fooBarbaz", "Foo", -1, -1, 0)
135
+ assertMatch(t, PrefixMatch, false, dir, "fooBarBaz", "baz", -1, -1, 0)
136
+ assertMatch(t, PrefixMatch, false, dir, "fooBarbaz", "Foo", 0, 3, score)
137
+ assertMatch(t, PrefixMatch, false, dir, "foOBarBaZ", "foo", 0, 3, score)
138
+ assertMatch(t, PrefixMatch, false, dir, "f-oBarbaz", "f-o", 0, 3, score)
139
+
140
+ assertMatch(t, PrefixMatch, false, dir, " fooBar", "foo", 1, 4, score)
141
+ assertMatch(t, PrefixMatch, false, dir, " fooBar", " fo", 0, 3, score)
142
+ assertMatch(t, PrefixMatch, false, dir, " fo", "foo", -1, -1, 0)
143
+ }
144
+ }
145
+
146
+ func TestSuffixMatch(t *testing.T) {
147
+ for _, dir := range []bool{true, false} {
148
+ assertMatch(t, SuffixMatch, true, dir, "fooBarbaz", "Baz", -1, -1, 0)
149
+ assertMatch(t, SuffixMatch, false, dir, "fooBarbaz", "Foo", -1, -1, 0)
150
+
151
+ assertMatch(t, SuffixMatch, false, dir, "fooBarbaz", "baz", 6, 9,
152
+ scoreMatch*3+bonusConsecutive*2)
153
+ assertMatch(t, SuffixMatch, false, dir, "fooBarBaZ", "baz", 6, 9,
154
+ (scoreMatch+bonusCamel123)*3+bonusCamel123*(bonusFirstCharMultiplier-1))
155
+
156
+ // Strip trailing white space from the string
157
+ assertMatch(t, SuffixMatch, false, dir, "fooBarbaz ", "baz", 6, 9,
158
+ scoreMatch*3+bonusConsecutive*2)
159
+ // Only when the pattern doesn't end with a space
160
+ assertMatch(t, SuffixMatch, false, dir, "fooBarbaz ", "baz ", 6, 10,
161
+ scoreMatch*4+bonusConsecutive*2+bonusNonWord)
162
+ }
163
+ }
164
+
165
+ func TestEmptyPattern(t *testing.T) {
166
+ for _, dir := range []bool{true, false} {
167
+ assertMatch(t, FuzzyMatchV1, true, dir, "foobar", "", 0, 0, 0)
168
+ assertMatch(t, FuzzyMatchV2, true, dir, "foobar", "", 0, 0, 0)
169
+ assertMatch(t, ExactMatchNaive, true, dir, "foobar", "", 0, 0, 0)
170
+ assertMatch(t, PrefixMatch, true, dir, "foobar", "", 0, 0, 0)
171
+ assertMatch(t, SuffixMatch, true, dir, "foobar", "", 6, 6, 0)
172
+ }
173
+ }
174
+
175
+ func TestNormalize(t *testing.T) {
176
+ caseSensitive := false
177
+ normalize := true
178
+ forward := true
179
+ test := func(input, pattern string, sidx, eidx, score int, funs ...Algo) {
180
+ for _, fun := range funs {
181
+ assertMatch2(t, fun, caseSensitive, normalize, forward,
182
+ input, pattern, sidx, eidx, score)
183
+ }
184
+ }
185
+ test("Só Danço Samba", "So", 0, 2, 56, FuzzyMatchV1, FuzzyMatchV2, PrefixMatch, ExactMatchNaive)
186
+ test("Só Danço Samba", "sodc", 0, 7, 89, FuzzyMatchV1, FuzzyMatchV2)
187
+ test("Danço", "danco", 0, 5, 128, FuzzyMatchV1, FuzzyMatchV2, PrefixMatch, SuffixMatch, ExactMatchNaive, EqualMatch)
188
+ }
189
+
190
+ func TestLongString(t *testing.T) {
191
+ bytes := make([]byte, math.MaxUint16*2)
192
+ for i := range bytes {
193
+ bytes[i] = 'x'
194
+ }
195
+ bytes[math.MaxUint16] = 'z'
196
+ assertMatch(t, FuzzyMatchV2, true, true, string(bytes), "zx", math.MaxUint16, math.MaxUint16+2, scoreMatch*2+bonusConsecutive)
197
+ }