Files
neovim/test/functional/lua
Yi Ming 9174157f74 feat(pos): pos:to_offset(), pos.offset() #39564
Problem:
For a given position, it is not easy to compare which of several other positions is closest to it.

Solution:
Add support for converting `vim.Pos` to a buffer byte offset.

This allows for sorting, e.g:
```lua
table.sort(positions, function(pos1, pos2)
  return pos1:to_offset() < pos2:to_offset()
end
```

Or a binary search, e.g:
```lua
vim.list.bisect(positions, pos, { key = function(pos) return pos:to_offset() end })
```
2026-05-06 16:37:16 -04:00
..
2024-04-23 18:17:04 +02:00
2025-01-09 09:26:45 -08:00
2024-04-23 18:17:04 +02:00
2026-03-29 13:36:56 +02:00