only filter history if not empty
This commit is contained in:
parent
ecfe78e04d
commit
63a247000b
1 changed files with 15 additions and 13 deletions
28
main.go
28
main.go
|
@ -74,21 +74,23 @@ func main() {
|
||||||
|
|
||||||
l := len(history)
|
l := len(history)
|
||||||
|
|
||||||
// wl-paste will always give back the last copied text
|
if l > 0 {
|
||||||
// (as long as the place we copied from is still running)
|
// wl-paste will always give back the last copied text
|
||||||
if history[l-1] == text {
|
// (as long as the place we copied from is still running)
|
||||||
time.Sleep(sleep)
|
if history[l-1] == text {
|
||||||
continue
|
time.Sleep(sleep)
|
||||||
}
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if l == max {
|
if l == max {
|
||||||
// we know that at any given time len(history) cannot be bigger than max,
|
// we know that at any given time len(history) cannot be bigger than max,
|
||||||
// so it's enough to drop the first element
|
// so it's enough to drop the first element
|
||||||
history = history[1:]
|
history = history[1:]
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove duplicates
|
// remove duplicates
|
||||||
history = filter(history, text)
|
history = filter(history, text)
|
||||||
|
}
|
||||||
|
|
||||||
history = append(history, text)
|
history = append(history, text)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue