diff options
| author | Abe Nonym <abe.nonym.mail@gmail.com> | 2021-07-17 13:53:05 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-17 13:53:05 +0200 |
| commit | 5b597e7709eec08331ce71b45193117f6fb5626b (patch) | |
| tree | bcdb40e745d8fab8b49041565113f65dbf32e73c /lua | |
| parent | 3f17192322a32da1bd445cd7153f00960480cb28 (diff) | |
fix: prevent error if preview scroll is triggered but no preview is available (#994)
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/telescope/actions/set.lua | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lua/telescope/actions/set.lua b/lua/telescope/actions/set.lua index 855400f..6ad786b 100644 --- a/lua/telescope/actions/set.lua +++ b/lua/telescope/actions/set.lua @@ -148,11 +148,18 @@ end ---@param direction number: The direction of the scrolling -- Valid directions include: "1", "-1" action_set.scroll_previewer = function (prompt_bufnr, direction) + local previewer = action_state.get_current_picker(prompt_bufnr).previewer + + -- Check if we actually have a previewer + if (type(previewer) ~= "table" or previewer.scroll_fn == nil) then + return + end + local status = state.get_status(prompt_bufnr) local default_speed = vim.api.nvim_win_get_height(status.preview_win) / 2 local speed = status.picker.layout_config.scroll_speed or default_speed - action_state.get_current_picker(prompt_bufnr).previewer:scroll_fn(math.floor(speed * direction)) + previewer:scroll_fn(math.floor(speed * direction)) end -- ================================================== |
