[vim/vim] Virtual text at end of line not truncated (Issue #12640)

11 views
Skip to first unread message

Elliot

unread,
Jul 6, 2023, 6:02:24 AM7/6/23
to vim/vim, Subscribed

Steps to reproduce

  1. Run vim --clean
  2. Source the following file:
40vsplit
call setline(1, repeat('a', 40))
call prop_type_add('test', {})
call prop_add(1, 0, {'type': 'test', 'text': 'bbb', 'text_wrap': 'truncate'})
  1. first line wraped

Expected behaviour

virtual text should not render

Version of Vim

9.0.1562

Environment

MacOS 13.4
terminal: wezterm 20230408-112425-69ae8472
shell: fish 3.6.1

Logs and stack traces

No response


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/12640@github.com>

Dylan Thacker-Smith

unread,
Feb 22, 2024, 6:38:56 PMFeb 22
to vim/vim, Subscribed

It looks like this is caused by this code

https://github.com/vim/vim/blob/315cd1fbcbba7c44ec8743f03645bfcaef58bd55/src/drawline.c#L628-L630

where PROP_TEXT_MIN_CELLS is 4 and your virtual text has only a length of 3. If the virtual text is longer, then you will see it truncated when there is space for 4 or more characters. Also, if wrapping is turned off in general with set nowrap, then you should also see the virtual text get truncated properly, even if there is room for less than 4 characters.

That makes it seem like the behaviour may be intentional, although using git log -p -G 'space < PROP_TEXT_MIN_CELLS' src/drawline.c I found that commit 04e0ed1 seems to have changed this behaviour from being exclusively for text_align: 'right' virtual text. The behaviour for text_align: 'right' virtual text is also different, since if less than 4 characters of that text fits, then it wraps from the start of that virtual text to the next line. In contrast to text_align: 'after' from your example splits up the text by trying to put the first 1-3 characters of the virtual text on the first line if there is room.

Given that context, I wonder it was intentional that this PROP_TEXT_MIN_CELLS behaviour affects virtual text other than text_align: 'right' or whether that was an unintentional bug.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/12640/1960516218@github.com>

Dylan Thacker-Smith

unread,
Feb 22, 2024, 7:32:01 PMFeb 22
to vim/vim, Subscribed

I looked for where the behaviour was introduced and although it moved around a bit, it looks like it has been that way since virtual text truncation was first implemented in commit 398649e


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/12640/1960569075@github.com>

Reply all
Reply to author
Forward
0 new messages