From 4626aaa2bcfdacf55fd6d44b430e2df81b2403ff Mon Sep 17 00:00:00 2001 From: Hannu Hartikainen Date: Tue, 2 Apr 2024 16:36:54 +0300 Subject: [PATCH] fix(scrolling): enhance and simplify scrolling (#3028) The previous scrolling implementation (#2687) moved the result selection by one item at a time, which isn't technically scrolling (ie. moving the view) and feels quite slow. Let the neovim builtin scrolling do its thing, so using the scroll wheel feels like scrolling and is functionally scrolling, too. Scrolling does not move the selection so after scrolling it typically makes sense to click. Moving the selection with keyboard takes you back to where you were. This is in line with typical desktop user interfaces. --- lua/telescope/actions/init.lua | 50 ---------------------------------- lua/telescope/mappings.lua | 40 --------------------------- 2 files changed, 90 deletions(-) diff --git a/lua/telescope/actions/init.lua b/lua/telescope/actions/init.lua index 928c287..a621a6f 100644 --- a/lua/telescope/actions/init.lua +++ b/lua/telescope/actions/init.lua @@ -1494,56 +1494,6 @@ end actions.nop = function(_) end -actions.mouse_scroll_up = function(prompt_bufnr) - local picker = action_state.get_current_picker(prompt_bufnr) - - local mouse_win = vim.fn.getmousepos().winid - if picker.results_win == mouse_win then - vim.schedule(function() - actions.move_selection_next(prompt_bufnr) - end) - return "" - else - return "" - end -end - -actions.mouse_scroll_down = function(prompt_bufnr) - local picker = action_state.get_current_picker(prompt_bufnr) - - local mouse_win = vim.fn.getmousepos().winid - if mouse_win == picker.results_win then - vim.schedule(function() - actions.move_selection_previous(prompt_bufnr) - end) - return "" - else - return "" - end -end - -actions.mouse_scroll_right = function(prompt_bufnr) - local picker = action_state.get_current_picker(prompt_bufnr) - - local mouse_win = vim.fn.getmousepos().winid - if mouse_win == picker.results_win then - return "" - else - return "" - end -end - -actions.mouse_scroll_left = function(prompt_bufnr) - local picker = action_state.get_current_picker(prompt_bufnr) - - local mouse_win = vim.fn.getmousepos().winid - if mouse_win == picker.results_win then - return "" - else - return "" - end -end - actions.mouse_click = function(prompt_bufnr) local picker = action_state.get_current_picker(prompt_bufnr) diff --git a/lua/telescope/mappings.lua b/lua/telescope/mappings.lua index b4b6473..90a4812 100644 --- a/lua/telescope/mappings.lua +++ b/lua/telescope/mappings.lua @@ -133,26 +133,6 @@ local mappings = {} mappings.default_mappings = config.values.default_mappings or { i = { - [""] = { - actions.mouse_scroll_up, - type = "action", - opts = { expr = true }, - }, - [""] = { - actions.mouse_scroll_down, - type = "action", - opts = { expr = true }, - }, - [""] = { - actions.mouse_scroll_right, - type = "action", - opts = { expr = true }, - }, - [""] = { - actions.mouse_scroll_left, - type = "action", - opts = { expr = true }, - }, [""] = { actions.mouse_click, type = "action", @@ -201,26 +181,6 @@ mappings.default_mappings = config.values.default_mappings [""] = actions.nop, }, n = { - [""] = { - actions.mouse_scroll_up, - type = "action", - opts = { expr = true }, - }, - [""] = { - actions.mouse_scroll_down, - type = "action", - opts = { expr = true }, - }, - [""] = { - actions.mouse_scroll_right, - type = "action", - opts = { expr = true }, - }, - [""] = { - actions.mouse_scroll_left, - type = "action", - opts = { expr = true }, - }, [""] = { actions.mouse_click, type = "action",