diff options
| author | Luis Calle <53507599+TheLeoP@users.noreply.github.com> | 2026-04-01 14:28:31 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-01 15:28:31 -0400 |
| commit | 79a2235fd16212ddcea9a7722dddabd3d927cdfd (patch) | |
| tree | fd9af3e5726ab5979b75cc8871ab4413ca7f706a /runtime/lua/vim | |
| parent | a2d9863c2773d69f41cc9aeba402e30fea474fdd (diff) | |
| download | rneovim-79a2235fd16212ddcea9a7722dddabd3d927cdfd.tar.gz rneovim-79a2235fd16212ddcea9a7722dddabd3d927cdfd.tar.bz2 rneovim-79a2235fd16212ddcea9a7722dddabd3d927cdfd.zip | |
perf(vim.pos): use `nvim_buf_line_count` instead of fetching all lines #38686
Diffstat (limited to 'runtime/lua/vim')
| -rw-r--r-- | runtime/lua/vim/pos.lua | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/runtime/lua/vim/pos.lua b/runtime/lua/vim/pos.lua index 34e65cef64..67e309db69 100644 --- a/runtime/lua/vim/pos.lua +++ b/runtime/lua/vim/pos.lua @@ -210,11 +210,11 @@ end ---@param pos vim.Pos ---@return integer, integer 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 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 col = #get_line(pos.buf, row) end |