From bdd47276636e5ffd0d6c08281a4d61e341521841 Mon Sep 17 00:00:00 2001 From: GustawXYZ <129527844+GustawXYZ@users.noreply.github.com> Date: Wed, 27 Sep 2023 01:29:08 +0200 Subject: [PATCH] Add option to not reverse select_next_item on bottom_up list (#1346) * add feature requested in (#1346) Add a parameter to the function preserve_mapping_verticality, which will keep mappings like and not reversed even when used custom view is used with `selection_order = 'top_down'` configuration. Example use configuration: ``` [""] = cmp.mapping(cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Select, preserve_mapping_verticality = true }, { "i", "s" }), [""] = cmp.mapping(cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Select, preserve_mapping_verticality = true }, { "i", "s" }), ``` --- lua/cmp/view/custom_entries_view.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/cmp/view/custom_entries_view.lua b/lua/cmp/view/custom_entries_view.lua index a5eca58b1..62a22da9e 100644 --- a/lua/cmp/view/custom_entries_view.lua +++ b/lua/cmp/view/custom_entries_view.lua @@ -285,7 +285,7 @@ end custom_entries_view.select_next_item = function(self, option) if self:visible() then local cursor = vim.api.nvim_win_get_cursor(self.entries_win.win)[1] - local is_top_down = self:is_direction_top_down() + local is_top_down = self:is_direction_top_down() or option.preserve_mapping_verticality local last = #self.entries if not self.entries_win:option('cursorline') then @@ -322,7 +322,7 @@ end custom_entries_view.select_prev_item = function(self, option) if self:visible() then local cursor = vim.api.nvim_win_get_cursor(self.entries_win.win)[1] - local is_top_down = self:is_direction_top_down() + local is_top_down = self:is_direction_top_down() or option.preserve_mapping_verticality local last = #self.entries if not self.entries_win:option('cursorline') then