mirror of
https://github.com/neovim/neovim.git
synced 2026-04-18 21:40:45 +00:00
perf(vim.pos): use nvim_buf_line_count instead of fetching all lines #38686
(cherry picked from commit 79a2235fd1)
This commit is contained in:
committed by
github-actions[bot]
parent
dee6d2ad97
commit
3de423eb20
@@ -210,11 +210,11 @@ end
|
|||||||
---@param pos vim.Pos
|
---@param pos vim.Pos
|
||||||
---@return integer, integer
|
---@return integer, integer
|
||||||
function Pos.to_extmark(pos)
|
function Pos.to_extmark(pos)
|
||||||
local line_num = #api.nvim_buf_get_lines(pos.buf, 0, -1, true)
|
local line_count = api.nvim_buf_line_count(pos.buf)
|
||||||
|
|
||||||
local row = pos.row
|
local row = pos.row
|
||||||
local col = pos.col
|
local col = pos.col
|
||||||
if pos.col == 0 and pos.row == line_num then
|
if pos.col == 0 and pos.row == line_count then
|
||||||
row = row - 1
|
row = row - 1
|
||||||
col = #get_line(pos.buf, row)
|
col = #get_line(pos.buf, row)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user