From 3328272ceb4d54073c185ac3aaf2dc2af3674233 Mon Sep 17 00:00:00 2001 From: Aaron Dill <117116764+aarondill@users.noreply.github.com> Date: Tue, 26 Mar 2024 01:35:58 -0500 Subject: [PATCH] fix: remove global `selection_mode` in `select_range` (#165) Pass as a parameter instead --- lua/tabnine/utils.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lua/tabnine/utils.lua b/lua/tabnine/utils.lua index d37935b..929b4e3 100644 --- a/lua/tabnine/utils.lua +++ b/lua/tabnine/utils.lua @@ -120,14 +120,17 @@ function M.set(array) return uniqueValues end -function M.select_range(range) +---Selects a given range of text +---@param range table +---@param selection_mode? 'charwise'|'linewise'|'blockwise'|'v'|'V'|'' +function M.select_range(range, selection_mode) local start_row, start_col, end_row, end_col = range[1][1], range[1][2], range[2][1], range[2][2] local v_table = { charwise = "v", linewise = "V", blockwise = "" } selection_mode = selection_mode or "charwise" -- Normalise selection_mode - if vim.tbl_contains(vim.tbl_keys(v_table), selection_mode) then selection_mode = v_table[selection_mode] end + selection_mode = v_table[selection_mode] or selection_mode -- enter visual mode if normal or operator-pending (no) mode -- Why? According to https://learnvimscriptthehardway.stevelosh.com/chapters/15.html