diff options
| author | Luis Calle <53507599+TheLeoP@users.noreply.github.com> | 2026-03-29 10:22:40 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-29 11:22:40 -0400 |
| commit | f3c2eb49bab344ae0c360141b0f377bf4b9fb3fc (patch) | |
| tree | e6339fad5e7453d82078bfff539c40ca0b23a3b6 /scripts/lintcommit.lua | |
| parent | 527684c8dd1d312a19d91784cfaa3ccf499ebfba (diff) | |
| download | rneovim-f3c2eb49bab344ae0c360141b0f377bf4b9fb3fc.tar.gz rneovim-f3c2eb49bab344ae0c360141b0f377bf4b9fb3fc.tar.bz2 rneovim-f3c2eb49bab344ae0c360141b0f377bf4b9fb3fc.zip | |
feat: extend vim.Pos, vim.Range #36397
Problem:
Using nested `vim.Pos` objects to represent each `vim.Range` object
requires 3 tables for each `vim.Range`, which may be undesirable in
performance critical code. Using key-value tables performs worse than
using array-like tables (lists).
Solution:
Use array-like indices for the internal fields of both `vim.Pos` and
`vim.Range` objects. Use a metatable to allow users to access them like
if they were key-value tables.
---
Problem:
The `vim.Pos` conversion interface for `extmark` indexing does not take
into account the difference in how a position on top of a newline is
represented in `vim.Pos` and `extmark`.
- `vim.Pos`: for a newline at the end of row `n`, `row` takes the value
`n + 1` and `col` takes the value `0`.
- `extmark`: for a newline at the end of for `n`, `row` takes the value
`n` and `col` takes the value `#row_text`.
Solution:
Handle this in the `extmark` interface.
---
Problem:
Not all `to_xxx` interfaces have wrapping objects like `to_lsp`.
Solution:
Return unwrapped values in `to_xxx` interfaces where it makes sense.
Accept unwrapped values in "from" interfaces where it makes sense.
---
Problem:
`start` and `end` positions have different semantics, so they can't be
compared. `vim.Range` relies on comparing the `end` and `start` of two
ranges to decide which one is greater, which doesn't work as expected
because this of the different semantics.
For example, for the ranges:
local a = {
start = { row = 0, col = 22, },
end_ = { row = 0, col = 24, },
}
local b = {
start = { row = 0, col = 17, },
end_ = { row = 0, col = 22, },
}
in this code:
local foo, bar = "foo", "bar"
-- |---||-|
-- b a
The range `b` is smaller than the range `a`, but the current
implementation compares `b._end` (`col = 22`) and `a.start` (`col = 22`)
and concludes that, since `b.col` is not smaller than `a.col`, `b`
should be greater than `a`.
Solution:
- Use a `to_inclusive_pos` to normalize end positions inside of
`vim.Range` whenever a comparison between a start and an end position
is necessary.
Diffstat (limited to 'scripts/lintcommit.lua')
0 files changed, 0 insertions, 0 deletions