summaryrefslogtreecommitdiffstats
path: root/src/charset.c
diff options
context:
space:
mode:
authorDylan Thacker-Smith <dylan.ah.smith@gmail.com>2024-03-24 09:43:25 +0100
committerChristian Brabandt <cb@256bit.org>2024-03-24 09:43:25 +0100
commitb2d124c6258ff41e1f951bf39a4afc386d79ddc4 (patch)
tree553f0db370d31fbdb8752e25aba51cb6cf70586b /src/charset.c
parentd3c0ff5d5a9076999a8504ee4d23a2c5abaf494e (diff)
patch 9.1.0200: `gj`/`gk` not skipping over outer virtual text linesv9.1.0200
Problem: `gj`/`gk` was updating the desired cursor virtual column to the outer virtual text, even though the actual cursor position was moved to not be on the virtual text, leading the need to do an extra `gj`/`gk` to move past each virtual text line. (rickhowe) Solution: Exclude the outer virtual text when getting the line length for moving the cursor with `gj`/`gk`, so that no extra movement is needed to skip over virtual text lines. (Dylan Thacker-Smith) fixes: #12028 related: #14262 Signed-off-by: Dylan Thacker-Smith <dylan.ah.smith@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src/charset.c')
-rw-r--r--src/charset.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/charset.c b/src/charset.c
index 5ae90da5db..c9584a90f7 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -798,6 +798,45 @@ linetabsize(win_T *wp, linenr_T lnum)
ml_get_buf(wp->w_buffer, lnum, FALSE), (colnr_T)MAXCOL);
}
+/*
+ * Like linetabsize(), but excludes 'above'/'after'/'right'/'below' aligned
+ * virtual text, while keeping inline virtual text.
+ */
+ int
+linetabsize_no_outer(win_T *wp, linenr_T lnum)
+{
+#ifndef FEAT_PROP_POPUP
+ return linetabsize(wp, lnum);
+#else
+ chartabsize_T cts;
+ char_u *line = ml_get_buf(wp->w_buffer, lnum, FALSE);
+
+ init_chartabsize_arg(&cts, wp, lnum, 0, line, line);
+
+ if (cts.cts_text_prop_count)
+ {
+ int write_idx = 0;
+ for (int read_idx = 0; read_idx < cts.cts_text_prop_count; read_idx++)
+ {
+ textprop_T *tp = &cts.cts_text_props[read_idx];
+ if (tp->tp_col != MAXCOL)
+ {
+ if (read_idx != write_idx)
+ cts.cts_text_props[write_idx] = *tp;
+ write_idx++;
+ }
+ }
+ cts.cts_text_prop_count = write_idx;
+ if (cts.cts_text_prop_count == 0)
+ VIM_CLEAR(cts.cts_text_props);
+ }
+
+ win_linetabsize_cts(&cts, (colnr_T)MAXCOL);
+ clear_chartabsize_arg(&cts);
+ return (int)cts.cts_vcol;
+#endif
+}
+
void
win_linetabsize_cts(chartabsize_T *cts, colnr_T len)
{