|
1 | 1 | local path = require "fzf-lua.path"
|
2 | 2 | local shell = require "fzf-lua.shell"
|
3 | 3 | local utils = require "fzf-lua.utils"
|
| 4 | +local libuv = require "fzf-lua.libuv" |
4 | 5 | local Object = require "fzf-lua.class"
|
5 | 6 |
|
6 | 7 | local api = vim.api
|
@@ -293,10 +294,27 @@ function Previewer.base:cmdline(_)
|
293 | 294 | end
|
294 | 295 |
|
295 | 296 | function Previewer.base:zero(_)
|
296 |
| - local act = string.format("execute-silent(%s)", |
| 297 | + -- |
| 298 | + -- debounce the zero event call to prevent reentry which may |
| 299 | + -- cause a hang of fzf or the nvim RPC server (#909) |
| 300 | + -- mkdir is an atomic operation and will fail if the directory |
| 301 | + -- already exists effectively creating a singleton shell command |
| 302 | + -- |
| 303 | + -- currently awaiting an upstream fix: |
| 304 | + -- https://github.com/junegunn/fzf/issues/3516 |
| 305 | + -- |
| 306 | + self._zero_lock = self._zero_lock |
| 307 | + or vim.fn.systemlist({ "mktemp", "--dry-run", "--suffix", ".fzf-lua-zero" })[1] |
| 308 | + local act = string.format("execute-silent(mkdir %s && %s)", |
| 309 | + libuv.shellescape(self._zero_lock), |
297 | 310 | shell.raw_action(function(_, _, _)
|
298 |
| - self:clear_preview_buf(true) |
299 |
| - self.last_entry = nil |
| 311 | + vim.defer_fn(function() |
| 312 | + if self.loaded_entry then |
| 313 | + self:clear_preview_buf(true) |
| 314 | + self.last_entry = nil |
| 315 | + end |
| 316 | + vim.fn.delete(self._zero_lock, "d") |
| 317 | + end, self.delay) |
300 | 318 | end, "", self.opts.debug))
|
301 | 319 | return act
|
302 | 320 | end
|
|
0 commit comments