feat(actions): support scrolling and selecting with the mouse (#2687)

* feat(scrolling and mouse support): support scrolling and selecting with the mouse

* fix ascending sorting_strategy mouse clicks

---------

Co-authored-by: James Trew <j.trew10@gmail.com>
This commit is contained in:
Sofronie Cristian
2024-03-30 06:05:03 +02:00
committed by GitHub
parent b22e6f6896
commit 1bb28df3cf
3 changed files with 150 additions and 1 deletions

View File

@@ -73,6 +73,7 @@ local function default_create_layout(picker)
local popup_opts = picker:get_window_options(vim.o.columns, line_count)
-- `popup.nvim` massaging so people don't have to remember minheight shenanigans
popup_opts.results.focusable = true
popup_opts.results.minheight = popup_opts.results.height
popup_opts.results.highlight = "TelescopeResultsNormal"
popup_opts.results.borderhighlight = "TelescopeResultsBorder"
@@ -81,7 +82,9 @@ local function default_create_layout(picker)
popup_opts.prompt.highlight = "TelescopePromptNormal"
popup_opts.prompt.borderhighlight = "TelescopePromptBorder"
popup_opts.prompt.titlehighlight = "TelescopePromptTitle"
if popup_opts.preview then
popup_opts.preview.focusable = true
popup_opts.preview.minheight = popup_opts.preview.height
popup_opts.preview.highlight = "TelescopePreviewNormal"
popup_opts.preview.borderhighlight = "TelescopePreviewBorder"
@@ -165,6 +168,7 @@ local function default_create_layout(picker)
popup.move(results_win, popup_opts.results)
popup.move(preview_win, popup_opts.preview)
else
popup_opts.preview.focusable = true
popup_opts.preview.highlight = "TelescopePreviewNormal"
popup_opts.preview.borderhighlight = "TelescopePreviewBorder"
popup_opts.preview.titlehighlight = "TelescopePreviewTitle"
@@ -528,6 +532,9 @@ function Picker:find()
self:close_existing_pickers()
self:reset_selection()
self.__original_mousemoveevent = vim.o.mousemoveevent
vim.o.mousemoveevent = true
self.original_win_id = a.nvim_get_current_win()
_, self.original_cword = pcall(vim.fn.expand, "<cword>")
@@ -1626,6 +1633,8 @@ function pickers.on_close_prompt(prompt_bufnr)
buffer = prompt_bufnr,
}
picker.close_windows(status)
vim.o.mousemoveevent = picker.__original_mousemoveevent
end
function pickers.on_resize_window(prompt_bufnr)