refactor(pos,range): extract vim.pos._util

Problem:
- To share logic, creating a `vim.Range` currently creates two `vim.Pos` values
  as intermediates, which causes unnecessary table allocations.
- `pos.lua` and `range.lua` contain some overlapping logic.

Solution:
Add `vim.pos._util`, a module for handling
positions represented directly by `row` and `col`.
This commit is contained in:
Yi Ming
2026-05-20 16:02:57 +08:00
parent 8d1233a144
commit b1c1f32089
7 changed files with 326 additions and 325 deletions

View File

@@ -133,9 +133,9 @@ local function sort_by_key(fn)
end
end
local get_lines = vim.pos._get_lines
local get_line = vim.pos._get_line
-- TODO(ofseed): remove these exported functions by replacing their usages with `vim.pos`.
local get_lines = require('vim.pos._util').get_lines
local get_line = require('vim.pos._util').get_line
--- Applies a list of text edits to a buffer. Note: this mutates `text_edits` (sorts in-place and
--- adds `_index` fields).