comparison src/normal.c @ 34623:65e7eaf68f19 v9.1.0200

patch 9.1.0200: `gj`/`gk` not skipping over outer virtual text lines Commit: https://github.com/vim/vim/commit/b2d124c6258ff41e1f951bf39a4afc386d79ddc4 Author: Dylan Thacker-Smith <dylan.ah.smith@gmail.com> Date: Sun Mar 24 09:43:25 2024 +0100 patch 9.1.0200: `gj`/`gk` not skipping over outer virtual text lines 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>
author Christian Brabandt <cb@256bit.org>
date Sun, 24 Mar 2024 10:00:05 +0100
parents dd8f5311cee5
children ad1b0609b2f8
comparison
equal deleted inserted replaced
34622:200db09e7504 34623:65e7eaf68f19
2304 * Return OK if able to move cursor, FAIL otherwise. 2304 * Return OK if able to move cursor, FAIL otherwise.
2305 */ 2305 */
2306 static int 2306 static int
2307 nv_screengo(oparg_T *oap, int dir, long dist) 2307 nv_screengo(oparg_T *oap, int dir, long dist)
2308 { 2308 {
2309 int linelen = linetabsize(curwin, curwin->w_cursor.lnum); 2309
2310 int linelen = linetabsize_no_outer(curwin, curwin->w_cursor.lnum);
2311
2310 int retval = OK; 2312 int retval = OK;
2311 int atend = FALSE; 2313 int atend = FALSE;
2312 int n; 2314 int n;
2313 int col_off1; // margin offset for first screen line 2315 int col_off1; // margin offset for first screen line
2314 int col_off2; // margin offset for wrapped screen line 2316 int col_off2; // margin offset for wrapped screen line
2374 retval = FAIL; 2376 retval = FAIL;
2375 break; 2377 break;
2376 } 2378 }
2377 cursor_up_inner(curwin, 1); 2379 cursor_up_inner(curwin, 1);
2378 2380
2379 linelen = linetabsize(curwin, curwin->w_cursor.lnum); 2381 linelen = linetabsize_no_outer(curwin, curwin->w_cursor.lnum);
2380 if (linelen > width1) 2382 if (linelen > width1)
2381 curwin->w_curswant += (((linelen - width1 - 1) / width2) 2383 curwin->w_curswant += (((linelen - width1 - 1) / width2)
2382 + 1) * width2; 2384 + 1) * width2;
2383 } 2385 }
2384 } 2386 }
2411 // when width1 < width2 (with cpoptions+=n). Subtract width2 2413 // when width1 < width2 (with cpoptions+=n). Subtract width2
2412 // to get a negative value for w_curswant, which will get 2414 // to get a negative value for w_curswant, which will get
2413 // clipped to column 0. 2415 // clipped to column 0.
2414 if (curwin->w_curswant >= width1) 2416 if (curwin->w_curswant >= width1)
2415 curwin->w_curswant -= width2; 2417 curwin->w_curswant -= width2;
2416 linelen = linetabsize(curwin, curwin->w_cursor.lnum); 2418 linelen = linetabsize_no_outer(curwin, curwin->w_cursor.lnum);
2417 } 2419 }
2418 } 2420 }
2419 } 2421 }
2420 } 2422 }
2421 2423