mirror of
https://github.com/folke/snacks.nvim
synced 2025-12-23 08:47:57 +00:00
fix(picker): do not record consecutive duplicate history (#2040)
## Description Before this fix, identical items are added to history repeatedly. This PR fixes this by only adding an item to history if it's different from the last recorded value. This doesn't completely remove duplicate entries in the history, it only prevents consecutive identical entries.
This commit is contained in:
parent
19ff343a16
commit
d0a5310417
1 changed files with 4 additions and 0 deletions
|
|
@ -53,6 +53,10 @@ function M:is_current()
|
|||
end
|
||||
|
||||
function M:record(value)
|
||||
-- don't record value if it's identical to the last recorded value
|
||||
if vim.deep_equal(self.kv:get(math.max(self.idx - 1, 1)), value) then
|
||||
return
|
||||
end
|
||||
self.kv:set(self.idx, value)
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue