Mercurial > vim
comparison src/move.c @ 32832:0503955dcd34 v9.0.1729
patch 9.0.1729: screenpos() wrong when w_skipcol and cpoptions+=n
Commit: https://github.com/vim/vim/commit/bfe377b8f2d080e5f85c8cbecf3533456e1d6312
Author: zeertzjq <zeertzjq@outlook.com>
Date: Thu Aug 17 22:58:53 2023 +0200
patch 9.0.1729: screenpos() wrong when w_skipcol and cpoptions+=n
Problem: screenpos() wrong result with w_skipcol and cpoptions+=n
Solution: Use adjust_plines_for_skipcol() instead of subtracting
w_skipcol.
closes: #12625
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 17 Aug 2023 23:15:02 +0200 |
parents | 6e1734ac14eb |
children | 522f16e3e058 |
comparison
equal
deleted
inserted
replaced
32831:6b08d6935217 | 32832:0503955dcd34 |
---|---|
1354 else | 1354 else |
1355 n = 0; | 1355 n = 0; |
1356 // don't skip more than necessary | 1356 // don't skip more than necessary |
1357 if (n > p_lines - curwin->w_height + 1) | 1357 if (n > p_lines - curwin->w_height + 1) |
1358 n = p_lines - curwin->w_height + 1; | 1358 n = p_lines - curwin->w_height + 1; |
1359 curwin->w_skipcol = n * width2; | 1359 if (n > 0) |
1360 curwin->w_skipcol = width1 + (n - 1) * width2; | |
1361 else | |
1362 curwin->w_skipcol = 0; | |
1360 } | 1363 } |
1361 else if (extra == 1) | 1364 else if (extra == 1) |
1362 { | 1365 { |
1363 // less than 'scrolloff' lines above, decrease skipcol | 1366 // less than 'scrolloff' lines above, decrease skipcol |
1364 extra = (curwin->w_skipcol + so * width2 - curwin->w_virtcol | 1367 extra = (curwin->w_skipcol + so * width2 - curwin->w_virtcol |
1441 int *ccolp, // cursor screen column | 1444 int *ccolp, // cursor screen column |
1442 int *ecolp) // end screen column | 1445 int *ecolp) // end screen column |
1443 { | 1446 { |
1444 colnr_T scol = 0, ccol = 0, ecol = 0; | 1447 colnr_T scol = 0, ccol = 0, ecol = 0; |
1445 int row = 0; | 1448 int row = 0; |
1446 int rowoff = 0; | |
1447 colnr_T coloff = 0; | 1449 colnr_T coloff = 0; |
1448 | 1450 |
1449 if (pos->lnum >= wp->w_topline && pos->lnum <= wp->w_botline) | 1451 if (pos->lnum >= wp->w_topline && pos->lnum <= wp->w_botline) |
1450 { | 1452 { |
1451 colnr_T col; | 1453 colnr_T col; |
1454 #ifdef FEAT_FOLDING | 1456 #ifdef FEAT_FOLDING |
1455 int is_folded; | 1457 int is_folded; |
1456 | 1458 |
1457 is_folded = hasFoldingWin(wp, lnum, &lnum, NULL, TRUE, NULL); | 1459 is_folded = hasFoldingWin(wp, lnum, &lnum, NULL, TRUE, NULL); |
1458 #endif | 1460 #endif |
1459 row = plines_m_win(wp, wp->w_topline, lnum - 1) + 1; | 1461 row = plines_m_win(wp, wp->w_topline, lnum - 1, FALSE) + 1; |
1462 // "row" should be the screen line where line "lnum" begins, which can | |
1463 // be negative if "lnum" is "w_topline" and "w_skipcol" is non-zero. | |
1464 row = adjust_plines_for_skipcol(wp, row); | |
1460 | 1465 |
1461 #ifdef FEAT_DIFF | 1466 #ifdef FEAT_DIFF |
1462 // Add filler lines above this buffer line. | 1467 // Add filler lines above this buffer line. |
1463 row += lnum == wp->w_topline ? wp->w_topfill | 1468 row += lnum == wp->w_topline ? wp->w_topfill |
1464 : diff_check_fill(wp, lnum); | 1469 : diff_check_fill(wp, lnum); |
1479 // similar to what is done in validate_cursor_col() | 1484 // similar to what is done in validate_cursor_col() |
1480 col = scol; | 1485 col = scol; |
1481 col += off; | 1486 col += off; |
1482 width = wp->w_width - off + win_col_off2(wp); | 1487 width = wp->w_width - off + win_col_off2(wp); |
1483 | 1488 |
1484 if (lnum == wp->w_topline) | |
1485 col -= wp->w_skipcol; | |
1486 | |
1487 // long line wrapping, adjust row | 1489 // long line wrapping, adjust row |
1488 if (wp->w_p_wrap | 1490 if (wp->w_p_wrap |
1489 && col >= (colnr_T)wp->w_width | 1491 && col >= (colnr_T)wp->w_width |
1490 && width > 0) | 1492 && width > 0) |
1491 { | 1493 { |
1492 // use same formula as what is used in curs_columns() | 1494 // use same formula as what is used in curs_columns() |
1493 rowoff = ((col - wp->w_width) / width + 1); | 1495 int rowoff = ((col - wp->w_width) / width + 1); |
1494 col -= rowoff * width; | 1496 col -= rowoff * width; |
1497 row += rowoff; | |
1495 } | 1498 } |
1496 col -= wp->w_leftcol; | 1499 col -= wp->w_leftcol; |
1497 if (col >= wp->w_width) | 1500 if (col >= wp->w_width) |
1498 col = -1; | 1501 col = -1; |
1499 if (col >= 0 && row + rowoff <= wp->w_height) | 1502 if (col >= 0 && row > 0 && row <= wp->w_height) |
1500 { | 1503 { |
1501 coloff = col - scol + wp->w_wincol + 1; | 1504 coloff = col - scol + wp->w_wincol + 1; |
1502 row += W_WINROW(wp); | 1505 row += W_WINROW(wp); |
1503 } | 1506 } |
1504 else | 1507 else |
1505 // character is left, right or below of the window | 1508 // character is out of the window |
1506 row = rowoff = scol = ccol = ecol = 0; | 1509 row = scol = ccol = ecol = 0; |
1507 } | 1510 } |
1508 } | 1511 } |
1509 *rowp = row + rowoff; | 1512 *rowp = row; |
1510 *scolp = scol + coloff; | 1513 *scolp = scol + coloff; |
1511 *ccolp = ccol + coloff; | 1514 *ccolp = ccol + coloff; |
1512 *ecolp = ecol + coloff; | 1515 *ecolp = ecol + coloff; |
1513 } | 1516 } |
1514 #endif | 1517 #endif |