Skip to content

Commit

Permalink
fix: Location component was showing wrong column with inlay hints. (#…
Browse files Browse the repository at this point in the history
…1243)

The location component had been previously changed to use
`vim.api.virtcol` (the screen position of the cursor) instead of
`vim.api.col` (the byte position of the cursor), in order to prevent
showing the wrong column when multibyte characters are present.
Unfortunately, the new inlay hints in neovim 0.10 make heavy use of
virtual text, and therefore the column shown in the location component
is often incorrect.

This change fixes it to use `vim.api.charcol`, which correctly handles
variable-width characters without including virtual text.
  • Loading branch information
davidt authored Jul 7, 2024
1 parent 942b586 commit e208967
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lua/lualine/components/location.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-- MIT license, see LICENSE for more details.
local function location()
local line = vim.fn.line('.')
local col = vim.fn.virtcol('.')
local col = vim.fn.charcol('.')
return string.format('%3d:%-2d', line, col)
end

Expand Down

0 comments on commit e208967

Please sign in to comment.