echasnovski / mini.nvim

Library of 40+ independent Lua modules improving overall Neovim (version 0.8 and higher) experience with minimal effort
MIT License
4.83k stars 182 forks source link

Statusline virtcol display doesn't respect neovim `positive count` requirement #1094

Closed wroyca closed 1 month ago

wroyca commented 1 month ago

Contributing guidelines

Module(s)

Statusline

Description

Hello o/.

Neovim requires positive count which is currently not respected by the virtcol display (perhaps by design?) in Mini.Statusline location section:

image

For the sake of this example, if you, e.g., type d0 to delete the empty line, Neovim will return an error, instead expecting d1.

image

One way to solve this is to set the minimum value to 1:

MiniStatusline.section_location = function(args)
  -- Use virtual column number to allow update when past last column
  if MiniStatusline.is_truncated(args.trunc_width) then return '%l│%2v' end

  -- Use `virtcol()` to correctly handle multi-byte characters
  return string.format('%%l|%%L│%%2v|%-2d', math.max(vim.fn.virtcol("$") - 1, 1))
end

image

echasnovski commented 1 month ago

Thanks for the issue!

This is indeed intentional and allows to differentiate truly empty line and a line with one character (possibly whitespace).

Closing as behavior is by design.


Neovim requires positive count which is currently not respected by the virtcol display (perhaps by design?) in Mini.Statusline location section:

I am not sure how total number of columns in the current line is related to count.

For the sake of this example, if you, e.g., type d0 to delete the empty line, Neovim will return an error, instead expecting d1.

I can not reproduce. The d0 executes d with 0 motion with no errors. The d1 requires a motion/textobject after typing it.

wroyca commented 1 month ago

I can not reproduce. The d0 executes d with 0 motion with no errors. The d1 requires a motion/textobject after typing it.

I should have specified that it must be run from the command line - My bad!

echasnovski commented 1 month ago

I should have specified that it must be run from the command line - My bad!

Ah, then it surely doesn't have anything to do with 0 being used as number of columns in current line. Because :d operates on lines and uses {count} as number of lines.