Fix clipboard history lock recovery and merged selection
This commit is contained in:
1 parent
2c02a79655
commit
0b3ba7fbe7
2 files changed
+63
-2
No files matched your search
@@ -134,6 +134,7 @@ func (p *Persistence) run(path string, watching bool) {
|
||||
defer tick.Stop()
|
||||
last := HistoryUpdate{State: p.Initial, Enabled: p.InitialEnabled}
|
||||
var signature string
|
||||
var retryLock bool
|
||||
var acknowledged uint64
|
||||
for {
|
||||
select {
|
||||
@@ -167,7 +168,7 @@ func (p *Persistence) run(path string, watching bool) {
|
||||
continue
|
||||
}
|
||||
nextSignature := history_signature(path)
|
||||
if nextSignature == signature {
|
||||
if nextSignature == signature && !retryLock {
|
||||
continue
|
||||
}
|
||||
file, err := acquire_history(path, false)
|
||||
@@ -182,16 +183,21 @@ func (p *Persistence) run(path string, watching bool) {
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
// Report a stable failure once, and retry after a file changes.
|
||||
// Report a stable failure once. Lock contention can clear without
|
||||
// changing either file, so it must also be retried on the next tick.
|
||||
if signature != nextSignature {
|
||||
p.report(err)
|
||||
}
|
||||
} else {
|
||||
if retryLock {
|
||||
p.report(nil)
|
||||
}
|
||||
if !reflect.DeepEqual(update, last) {
|
||||
p.publish(update)
|
||||
last = update
|
||||
}
|
||||
}
|
||||
retryLock = errors.Is(err, syscall.EWOULDBLOCK)
|
||||
signature = nextSignature
|
||||
}
|
||||
}
|
||||
@@ -294,6 +300,7 @@ func apply_history(path string, job historyJob) (HistoryUpdate, error) {
|
||||
}
|
||||
if !found {
|
||||
state.Entries = append([]string{text}, state.Entries...)
|
||||
state.Selected++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user