Cursor is not positioned correctly with virtual text

12 views
Skip to first unread message

Yegappan Lakshmanan

unread,
Dec 31, 2022, 5:18:16 PM12/31/22
to vim_dev
Hi,

When a virtual text is truncated, cursor positioning is incorrect. I am seeing
this issue when using inlay hints with the Vim9 LSP plugin.

To see this issue, source the following test script:

-----------------------------------------------------------------------------------------
new
call prop_type_add('Param', #{highlight: 'Conceal'})
call setline(1, "\t\t\t\tif (var_check_fixed(test_flag, arg_errmsg, gettext))")
call prop_add(1, 25, #{type: 'Param', text: 'flags: '})
call prop_add(1, 36, #{type: 'Param', text: 'long_name_arg: '})
-----------------------------------------------------------------------------------------

After sourcing the above script, press '$' on line 1. You will see that the
cursor is positioned some columns after the last character. Also, if you
press '%' from one of the opening parenthesis on this line, you will
see that the cursor is not correctly positioned at the closing parenthesis.

Regards,
Yegappan

Bram Moolenaar

unread,
Jan 1, 2023, 8:51:40 AM1/1/23
to vim...@googlegroups.com, Yegappan Lakshmanan
Two places in the code don't agree what happens with virtual text that
is placed somewhere inside the line. When drawing the text it is
truncated at the window edge, when computing the cursor position it is
not truncated.

I actually do not see a good reason why this text would be truncated at
the window edge. It is inserted at a certain position in the text,
there is no relation whether this is close to the window edge or not.

Let me not truncated the text, see if any tests fail. If that seems to
work we'll have to see if some users depended on the truncation.

--
FROG: How you English say: I one more time, mac, I unclog my nose towards
you, sons of a window-dresser, so, you think you could out-clever us
French fellows with your silly knees-bent creeping about advancing
behaviour. (blows a raspberry) I wave my private parts at your aunties,
you brightly-coloured, mealy-templed, cranberry-smelling, electric
donkey-bottom biters.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages