Mercurial > vim
comparison src/drawline.c @ 29918:e6e0f1c39edb v9.0.0297
patch 9.0.0297: cursor position wrong after right aligned virtual text
Commit: https://github.com/vim/vim/commit/c8bf59e9b27f9d621818ffc61468abef45cedf37
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Aug 28 16:39:22 2022 +0100
patch 9.0.0297: cursor position wrong after right aligned virtual text
Problem: Cursor position wrong after right aligned virtual text. (Iizuka
Masashi)
Solution: Take the width of the column offset into account. (closes #10997)
Also fix virtual text positioning.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 28 Aug 2022 17:45:03 +0200 |
parents | bbe62ea78aac |
children | 4b9b237d1211 |
comparison
equal
deleted
inserted
replaced
29917:a25eab5e4117 | 29918:e6e0f1c39edb |
---|---|
300 int below = (tp->tp_flags & TP_FLAG_ALIGN_BELOW); | 300 int below = (tp->tp_flags & TP_FLAG_ALIGN_BELOW); |
301 int wrap = (tp->tp_flags & TP_FLAG_WRAP); | 301 int wrap = (tp->tp_flags & TP_FLAG_WRAP); |
302 int padding = tp->tp_col == MAXCOL && tp->tp_len > 1 | 302 int padding = tp->tp_col == MAXCOL && tp->tp_len > 1 |
303 ? tp->tp_len - 1 : 0; | 303 ? tp->tp_len - 1 : 0; |
304 int col_with_padding = vcol + (below ? 0 : padding); | 304 int col_with_padding = vcol + (below ? 0 : padding); |
305 int col_off = 0; | |
305 int room = wp->w_width - col_with_padding; | 306 int room = wp->w_width - col_with_padding; |
306 int added = room; | 307 int added = room; |
307 int n_used = *n_extra; | 308 int n_used = *n_extra; |
308 char_u *l = NULL; | 309 char_u *l = NULL; |
309 int strsize = vim_strsize(*p_extra); | 310 int strsize = vim_strsize(*p_extra); |
322 : (n_used < *n_extra))) | 323 : (n_used < *n_extra))) |
323 { | 324 { |
324 if (right && (wrap || room < PROP_TEXT_MIN_CELLS)) | 325 if (right && (wrap || room < PROP_TEXT_MIN_CELLS)) |
325 { | 326 { |
326 // right-align on next line instead of wrapping if possible | 327 // right-align on next line instead of wrapping if possible |
327 added = wp->w_width - strsize + room; | 328 col_off = win_col_off(wp) + win_col_off2(wp); |
329 added = wp->w_width - col_off - strsize + room; | |
328 if (added < 0) | 330 if (added < 0) |
329 added = 0; | 331 added = 0; |
330 else | 332 else |
331 n_used = *n_extra; | 333 n_used = *n_extra; |
332 } | 334 } |
384 *lp = '>'; | 386 *lp = '>'; |
385 } | 387 } |
386 *p_extra = l; | 388 *p_extra = l; |
387 *n_extra = n_used + added + padding; | 389 *n_extra = n_used + added + padding; |
388 *n_attr = mb_charlen(*p_extra); | 390 *n_attr = mb_charlen(*p_extra); |
389 *n_attr_skip = added + padding; | 391 *n_attr_skip = added + padding + col_off; |
390 } | 392 } |
391 } | 393 } |
392 } | 394 } |
393 | 395 |
394 if (n_attr == NULL) | 396 if (n_attr == NULL) |