Skip to content

Commit a94f192

Browse files
fix: min-store-length sets max length instead of min (#163)
* fix: min-store-length sets max length instead of min * fix: min-store-length test * add more test --------- Co-authored-by: sentriz <senan@senan.xyz>
1 parent 6eda526 commit a94f192

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

cliphist.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func store(dbPath string, in io.Reader, maxDedupeSearch, maxItems uint64, minLen
107107
if len(input) > 5*1e6 { // don't store >5MB
108108
return nil
109109
}
110-
if int(minLength) > 0 && graphemeClusterCount(string(input)) > int(minLength) {
110+
if int(minLength) > 0 && graphemeClusterCount(string(input)) < int(minLength) {
111111
return nil
112112
}
113113

testdata/min-store-length.txtar

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,22 @@ exec randstr 4
1414
stdin stdout
1515
exec cliphist -min-store-length 3 store
1616

17-
# we didn't store the last, 4 > 3
17+
# we can store the last, since 4 > 3
1818
exec cliphist list
19-
stdout -count=2 '^.'
19+
stdout -count=3 '^.'
20+
21+
exec randstr 2
22+
stdin stdout
23+
exec cliphist -min-store-length 3 store
24+
25+
# not the last, since 4 > 3
26+
exec cliphist list
27+
stdout -count=3 '^.'
28+
29+
exec randstr 3
30+
stdin stdout
31+
exec cliphist -min-store-length 3 store
32+
33+
# last is fine, 3 == 3
34+
exec cliphist list
35+
stdout -count=4 '^.'

0 commit comments

Comments
 (0)