Skip to content

Commit f303aed

Browse files
committed
fix: use SIGWINCH to force fzf to redraw screen
Since I bind my `ctrl-l` to other actions rather than `clear-screen` so I spot this upsteram bug again kevinhwang91@bdc2a4e. `resize` can trigger `clear-screen` in fzf. So this might be a better way to force `redraw` in linux. Related: * ibhagwan/fzf-lua#1871 * ibhagwan/fzf-lua#1901 (reply in thread) > * By `resize` there's false positive: e.g. windows manager users may often resize window manualy > * And I'm not sure `SIGWINCH` and fzf's `resize` work correctly on Windows. > * By `chan_send`/`feedkeys` we override user's key bindings (although there's already some `chan_send` hacks in codebase like: toggling preview (this is handled better by scanning user's fzf bindings config... but will be weird if user set bindings from `FZF_DEFAULT_OPTS`), mirroring the `esc` to fzf (this is opt-in by a hide profile).
1 parent ebb6d26 commit f303aed

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

lua/bqf/preview/session.lua

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
local api = vim.api
22
local cmd = vim.cmd
3+
local uv = vim.uv or vim.loop
34

45
---@type BqfPreviewTitle
56
local title
@@ -187,8 +188,12 @@ function PreviewSession:display(pwinid, pbufnr, idx, size, handler)
187188
-- like scrollbar, clear screen manually.
188189
if hasShowedScrollBar == false and floatwin.showScrollBar == true and utils.has10() and
189190
api.nvim_get_mode().mode == 't' then
190-
-- ^L = 0x0c
191-
api.nvim_feedkeys(('%c'):format(0x0c), 'it', false)
191+
if utils.isWindows() then -- ^L = 0x0c
192+
api.nvim_feedkeys(('%c'):format(0x0c), 'it', false)
193+
else -- SIGWINCH to force fzf redraw on resize
194+
vim.tbl_map(function(pid) uv.kill(pid, 28) end,
195+
vim._os_proc_children(vim.fn.jobpid(vim.bo.channel)))
196+
end
192197
end
193198
end
194199
end

0 commit comments

Comments
 (0)