Mercurial > vim
comparison src/normal.c @ 32535:72fd0421c183 v9.0.1599
patch 9.0.1599: Cursor not adjusted when 'splitkeep' is not "cursor"
Commit: https://github.com/vim/vim/commit/a109f39ef54bc3894768170f02c1b6ac56164488
Author: Luuk van Baal <luukvbaal@gmail.com>
Date: Fri Jun 2 14:16:35 2023 +0100
patch 9.0.1599: Cursor not adjusted when 'splitkeep' is not "cursor"
Problem: Cursor not adjusted when near top or bottom of window and
'splitkeep' is not "cursor".
Solution: Move boundary checks to outer cursor move functions, inner
functions should only return valid cursor positions. (Luuk van
Baal, closes #12480)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 02 Jun 2023 15:30:04 +0200 |
parents | 11bc7fa31c3b |
children | 448aef880252 |
comparison
equal
deleted
inserted
replaced
32534:f139a13965f2 | 32535:72fd0421c183 |
---|---|
2357 // which will get clipped to column 0. | 2357 // which will get clipped to column 0. |
2358 curwin->w_curswant -= width2; | 2358 curwin->w_curswant -= width2; |
2359 else | 2359 else |
2360 { | 2360 { |
2361 // to previous line | 2361 // to previous line |
2362 if (!cursor_up_inner(curwin, 1)) | 2362 if (curwin->w_cursor.lnum <= 1) |
2363 { | 2363 { |
2364 retval = FAIL; | 2364 retval = FAIL; |
2365 break; | 2365 break; |
2366 } | 2366 } |
2367 cursor_up_inner(curwin, 1); | |
2368 | |
2367 linelen = linetabsize_str(ml_get_curline()); | 2369 linelen = linetabsize_str(ml_get_curline()); |
2368 if (linelen > width1) | 2370 if (linelen > width1) |
2369 curwin->w_curswant += (((linelen - width1 - 1) / width2) | 2371 curwin->w_curswant += (((linelen - width1 - 1) / width2) |
2370 + 1) * width2; | 2372 + 1) * width2; |
2371 } | 2373 } |
2384 // move forward within line | 2386 // move forward within line |
2385 curwin->w_curswant += width2; | 2387 curwin->w_curswant += width2; |
2386 else | 2388 else |
2387 { | 2389 { |
2388 // to next line | 2390 // to next line |
2389 if (!cursor_down_inner(curwin, 1)) | 2391 if (curwin->w_cursor.lnum |
2392 >= curwin->w_buffer->b_ml.ml_line_count) | |
2390 { | 2393 { |
2391 retval = FAIL; | 2394 retval = FAIL; |
2392 break; | 2395 break; |
2393 } | 2396 } |
2397 cursor_down_inner(curwin, 1); | |
2394 curwin->w_curswant %= width2; | 2398 curwin->w_curswant %= width2; |
2399 | |
2395 // Check if the cursor has moved below the number display | 2400 // Check if the cursor has moved below the number display |
2396 // when width1 < width2 (with cpoptions+=n). Subtract width2 | 2401 // when width1 < width2 (with cpoptions+=n). Subtract width2 |
2397 // to get a negative value for w_curswant, which will get | 2402 // to get a negative value for w_curswant, which will get |
2398 // clipped to column 0. | 2403 // clipped to column 0. |
2399 if (curwin->w_curswant >= width1) | 2404 if (curwin->w_curswant >= width1) |