fix: check for window before scrolling previewer (#2163)
This avoids an error when scrolling the preview window but the window is not visible (e.g. due to a screen resize).
This commit is contained in:
committed by
GitHub
parent
4a43d13c95
commit
30e2dc5232
@@ -185,13 +185,13 @@ end
|
|||||||
-- Valid directions include: "1", "-1"
|
-- Valid directions include: "1", "-1"
|
||||||
action_set.scroll_previewer = function(prompt_bufnr, direction)
|
action_set.scroll_previewer = function(prompt_bufnr, direction)
|
||||||
local previewer = action_state.get_current_picker(prompt_bufnr).previewer
|
local previewer = action_state.get_current_picker(prompt_bufnr).previewer
|
||||||
|
local status = state.get_status(prompt_bufnr)
|
||||||
|
|
||||||
-- Check if we actually have a previewer
|
-- Check if we actually have a previewer and a preview window
|
||||||
if type(previewer) ~= "table" or previewer.scroll_fn == nil then
|
if type(previewer) ~= "table" or previewer.scroll_fn == nil or status.preview_win == nil then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local status = state.get_status(prompt_bufnr)
|
|
||||||
local default_speed = vim.api.nvim_win_get_height(status.preview_win) / 2
|
local default_speed = vim.api.nvim_win_get_height(status.preview_win) / 2
|
||||||
local speed = status.picker.layout_config.scroll_speed or default_speed
|
local speed = status.picker.layout_config.scroll_speed or default_speed
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user