diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-08-28 06:36:51 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-28 06:36:51 +0800 |
commit | d7d3d757c1e9dc1c204764722623a9b0ae41eb83 (patch) | |
tree | 224f2ef542ff1e727e317c2a71eecc48218b6326 /src | |
parent | abb8c2c453d1e084f8ab3e9bbaa8b27515c81a9f (diff) | |
parent | 062db5c136700c35ff700fa4567b6ec8042539c7 (diff) | |
download | rneovim-d7d3d757c1e9dc1c204764722623a9b0ae41eb83.tar.gz rneovim-d7d3d757c1e9dc1c204764722623a9b0ae41eb83.tar.bz2 rneovim-d7d3d757c1e9dc1c204764722623a9b0ae41eb83.zip |
Merge pull request #24853 from zeertzjq/inline-virt-eol
fix(ui): wrong cursor position with left gravity inline virt text at eol
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/drawline.c | 8 | ||||
-rw-r--r-- | src/nvim/move.c | 9 | ||||
-rw-r--r-- | src/nvim/plines.c | 8 |
3 files changed, 10 insertions, 15 deletions
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c index 31ca9b16ce..7e92128b65 100644 --- a/src/nvim/drawline.c +++ b/src/nvim/drawline.c @@ -868,8 +868,8 @@ static void apply_cursorline_highlight(win_T *wp, winlinevars_T *wlv) } } -// Checks if there is more inline virtual text that need to be drawn -// and sets has_more_virt_inline_chunks to reflect that. +/// Checks if there is more inline virtual text that need to be drawn +/// and sets has_more_virt_inline_chunks to reflect that. static bool has_more_inline_virt(winlinevars_T *wlv, ptrdiff_t v) { DecorState *state = &decor_state; @@ -3096,8 +3096,8 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl || wlv.filler_todo > 0 || (wp->w_p_list && wp->w_p_lcs_chars.eol != NUL && wlv.p_extra != at_end_str) - || (wlv.n_extra != 0 - && (wlv.c_extra != NUL || *wlv.p_extra != NUL)) || wlv.more_virt_inline_chunks)) { + || (wlv.n_extra != 0 && (wlv.c_extra != NUL || *wlv.p_extra != NUL)) + || wlv.more_virt_inline_chunks)) { bool wrap = wp->w_p_wrap // Wrapping enabled. && wlv.filler_todo <= 0 // Not drawing diff filler lines. && lcs_eol_one != -1 // Haven't printed the lcs_eol character. diff --git a/src/nvim/move.c b/src/nvim/move.c index 0077dc3102..3978539df6 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -862,15 +862,6 @@ void curs_columns(win_T *wp, int may_scroll) n = (wp->w_wcol - wp->w_width_inner) / width2 + 1; wp->w_wcol -= n * width2; wp->w_wrow += n; - - // When cursor wraps to first char of next line in Insert - // mode, the 'showbreak' string isn't shown, backup to first - // column - char *const sbr = get_showbreak_value(wp); - if (*sbr && *get_cursor_pos_ptr() == NUL - && wp->w_wcol == (wp->w_width_inner - width2) + vim_strsize(sbr)) { - wp->w_wcol = 0; - } } } else if (may_scroll && !wp->w_cline_folded) { diff --git a/src/nvim/plines.c b/src/nvim/plines.c index c95f362518..b95adc1415 100644 --- a/src/nvim/plines.c +++ b/src/nvim/plines.c @@ -359,7 +359,7 @@ int win_lbr_chartabsize(chartabsize_T *cts, int *headp) if (width <= 0) { width = 1; } - // divide "size - prev_width" by "width", rounding up + // Divide "size - prev_rem" by "width", rounding up. int cnt = (size - prev_rem + width - 1) / width; added += cnt * head_mid; @@ -371,7 +371,11 @@ int win_lbr_chartabsize(chartabsize_T *cts, int *headp) } else if (max_head_vcol < 0) { int off = virt_text_cursor_off(cts, c == NUL); if (off >= prev_rem) { - head += (1 + (off - prev_rem) / width) * head_mid; + if (size > off) { + head += (1 + (off - prev_rem) / width) * head_mid; + } else { + head += (off - prev_rem + width - 1) / width * head_mid; + } } } } |