From 2061fcbf3b5db692f4d27d49796418f8f93b7539 Mon Sep 17 00:00:00 2001 From: Andrey Mishakin Date: Sun, 11 Sep 2022 21:32:09 +0300 Subject: [PATCH] fix: display virtual column number in location component (#835) --- lua/lualine/components/location.lua | 2 +- tests/spec/component_spec.lua | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lua/lualine/components/location.lua b/lua/lualine/components/location.lua index 413bf9e..1b276ac 100644 --- a/lua/lualine/components/location.lua +++ b/lua/lualine/components/location.lua @@ -2,7 +2,7 @@ -- MIT license, see LICENSE for more details. local function location() local line = vim.fn.line('.') - local col = vim.fn.col('.') + local col = vim.fn.virtcol('.') return string.format('%3d:%-2d', line, col) end diff --git a/tests/spec/component_spec.lua b/tests/spec/component_spec.lua index d0a2cc2..48c1990 100644 --- a/tests/spec/component_spec.lua +++ b/tests/spec/component_spec.lua @@ -405,6 +405,12 @@ describe('Location component', function() assert_component('location', opts, ' 10:1 ') vim.api.nvim_win_set_cursor(0, {5, 0}) assert_component('location', opts, ' 5:1 ') + -- test column number + vim.cmd('normal! oTest') + assert_component('location', opts, ' 6:4 ') + -- test column number in line containing cyrillic symbols + vim.cmd('normal! oТест') + assert_component('location', opts, ' 7:4 ') vim.cmd('bdelete!') end) end)