From 3d188a0365bd5291123b87540be84488114b4968 Mon Sep 17 00:00:00 2001 From: Yi Ming Date: Wed, 21 Aug 2024 01:11:17 +0800 Subject: [PATCH] refactor(shared): better convertion function name --- lua/nvim-treesitter-textobjects/move.lua | 2 +- lua/nvim-treesitter-textobjects/select.lua | 2 +- lua/nvim-treesitter-textobjects/shared.lua | 6 +++--- lua/nvim-treesitter-textobjects/swap.lua | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lua/nvim-treesitter-textobjects/move.lua b/lua/nvim-treesitter-textobjects/move.lua index 3c6cfc82..ff1d4789 100644 --- a/lua/nvim-treesitter-textobjects/move.lua +++ b/lua/nvim-treesitter-textobjects/move.lua @@ -128,7 +128,7 @@ local function move(opts) end end end - goto_node(best_range and shared.range6_range4(best_range), not best_start, not config.set_jumps) + goto_node(best_range and shared.torange4(best_range), not best_start, not config.set_jumps) end end diff --git a/lua/nvim-treesitter-textobjects/select.lua b/lua/nvim-treesitter-textobjects/select.lua index 12e161f7..a9ba1126 100644 --- a/lua/nvim-treesitter-textobjects/select.lua +++ b/lua/nvim-treesitter-textobjects/select.lua @@ -160,7 +160,7 @@ function M.select_textobject(query_string, query_group) { lookahead = lookahead, lookbehind = lookbehind } ) if range6 then - local range4 = shared.range6_range4(range6) + local range4 = shared.torange4(range6) local selection_mode = M.detect_selection_mode(query_string) if function_or_value_to_value(surrounding_whitespace, { diff --git a/lua/nvim-treesitter-textobjects/shared.lua b/lua/nvim-treesitter-textobjects/shared.lua index 1d74cb31..14c52c75 100644 --- a/lua/nvim-treesitter-textobjects/shared.lua +++ b/lua/nvim-treesitter-textobjects/shared.lua @@ -243,7 +243,7 @@ end ---@param range Range6 ---@return Range4 -function M.range6_range4(range) +function M.torange4(range) return { range[1], range[2], range[4], range[5] } end @@ -269,7 +269,7 @@ local function best_range_at_point(ranges, row, col, opts) local lookbehind_earliest_start ---@type integer for _, range in pairs(ranges) do - if range and is_in_range(M.range6_range4(range), row, col) then + if range and is_in_range(M.torange4(range), row, col) then local length = range[6] - range[3] if not range_length or length < range_length then smallest_range = range @@ -380,7 +380,7 @@ function M.textobject_at_point(query_string, query_group, bufnr, pos, opts) local ranges_within_outer = {} for _, range in ipairs(ranges) do - if contains(M.range6_range4(range_outer), M.range6_range4(range)) then + if contains(M.torange4(range_outer), M.torange4(range)) then table.insert(ranges_within_outer, range) end end diff --git a/lua/nvim-treesitter-textobjects/swap.lua b/lua/nvim-treesitter-textobjects/swap.lua index aadfb776..ac540f38 100644 --- a/lua/nvim-treesitter-textobjects/swap.lua +++ b/lua/nvim-treesitter-textobjects/swap.lua @@ -179,7 +179,7 @@ local function swap_textobject(captures, query_group, direction) local adjacent = direction > 0 and next_textobject(textobject_range, query_string, query_group, bufnr) or previous_textobject(textobject_range, query_string, query_group, bufnr) if adjacent then - swap_nodes(shared.range6_range4(textobject_range), shared.range6_range4(adjacent), bufnr, "yes, set cursor!") + swap_nodes(shared.torange4(textobject_range), shared.torange4(adjacent), bufnr, "yes, set cursor!") end end end