aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/plines.c
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2023-05-09 14:26:03 +0200
committerbfredl <bjorn.linse@gmail.com>2023-05-22 13:49:42 +0200
commita78fd18ed92d7474d10b5640dcf7a15728d2e03a (patch)
tree9123221c9391e661771288d03fdfa704b003ef13 /src/nvim/plines.c
parent29da1a9cf0b44f2edcbff9e45af283f235360947 (diff)
downloadrneovim-a78fd18ed92d7474d10b5640dcf7a15728d2e03a.tar.gz
rneovim-a78fd18ed92d7474d10b5640dcf7a15728d2e03a.tar.bz2
rneovim-a78fd18ed92d7474d10b5640dcf7a15728d2e03a.zip
fix(extmark): fix cursor position with both left and right gravity inline text
Diffstat (limited to 'src/nvim/plines.c')
-rw-r--r--src/nvim/plines.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/nvim/plines.c b/src/nvim/plines.c
index 3b4883d5c2..25c745ae97 100644
--- a/src/nvim/plines.c
+++ b/src/nvim/plines.c
@@ -269,7 +269,7 @@ int linetabsize_col(int startcol, char *s)
if (cts.cts_has_virt_text && cts.cts_ptr == cts.cts_line) {
// check for virtual text in an empty line
(void)lbr_chartabsize_adv(&cts);
- cts.cts_vcol += cts.cts_cur_text_width;
+ cts.cts_vcol += cts.cts_cur_text_width_left + cts.cts_cur_text_width_right;
}
clear_chartabsize_arg(&cts);
return cts.cts_vcol;
@@ -308,7 +308,7 @@ void win_linetabsize_cts(chartabsize_T *cts, colnr_T len)
if (cts->cts_has_virt_text && *cts->cts_ptr == NUL
&& cts->cts_ptr == cts->cts_line) {
(void)win_lbr_chartabsize(cts, NULL);
- cts->cts_vcol += cts->cts_cur_text_width;
+ cts->cts_vcol += cts->cts_cur_text_width_left + cts->cts_cur_text_width_right;
}
}
@@ -323,9 +323,9 @@ void init_chartabsize_arg(chartabsize_T *cts, win_T *wp, linenr_T lnum, colnr_T
cts->cts_vcol = col;
cts->cts_line = line;
cts->cts_ptr = ptr;
- cts->cts_cur_text_width = 0;
+ cts->cts_cur_text_width_left = 0;
+ cts->cts_cur_text_width_right = 0;
cts->cts_has_virt_text = false;
- cts->cts_has_right_gravity = true;
cts->cts_row = lnum - 1;
if (cts->cts_row >= 0) {
@@ -398,7 +398,8 @@ int win_lbr_chartabsize(chartabsize_T *cts, int *headp)
int mb_added = 0;
int numberextra;
- cts->cts_cur_text_width = 0;
+ cts->cts_cur_text_width_left = 0;
+ cts->cts_cur_text_width_right = 0;
// No 'linebreak', 'showbreak' and 'breakindent': return quickly.
if (!wp->w_p_lbr && !wp->w_p_bri && *get_showbreak_value(wp) == NUL
@@ -419,14 +420,15 @@ int win_lbr_chartabsize(chartabsize_T *cts, int *headp)
mtkey_t mark = marktree_itr_current(cts->cts_iter);
if (mark.pos.row != cts->cts_row || mark.pos.col > col) {
break;
- } else if (mark.pos.col >= col
- && mark.pos.col < col + charlen) { // TODO(bfredl): or maybe unconditionally, what
- // if byte-misaligned?
+ } else if (mark.pos.col >= col && mark.pos.col < col + charlen) {
if (!mt_end(mark)) {
Decoration decor = get_decor(mark);
if (decor.virt_text_pos == kVTInline) {
- cts->cts_cur_text_width += decor.virt_text_width;
- cts->cts_has_right_gravity = mt_right(mark);
+ if (mt_right(mark)) {
+ cts->cts_cur_text_width_right += decor.virt_text_width;
+ } else {
+ cts->cts_cur_text_width_left += decor.virt_text_width;
+ }
size += decor.virt_text_width;
if (*s == TAB) {
// tab size changes because of the inserted text