Mercurial > vim
comparison src/drawscreen.c @ 18601:e4b03b369c41 v8.1.2294
patch 8.1.2294: cursor pos wrong with concealing and search causes a scroll
Commit: https://github.com/vim/vim/commit/cbee635eee3007db97646ddb9f211a1d4966eb2a
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Nov 12 20:49:15 2019 +0100
patch 8.1.2294: cursor pos wrong with concealing and search causes a scroll
Problem: Cursor position wrong when characters are concealed and asearch
causes a scroll.
Solution: Fix the cursor column in a concealed line after window scroll.
(closes #5215, closes #5012)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 12 Nov 2019 21:00:03 +0100 |
parents | 78e43be18f6b |
children | 49b78d6465e5 |
comparison
equal
deleted
inserted
replaced
18600:f3a97183ab01 | 18601:e4b03b369c41 |
---|---|
1396 int eof = FALSE; // if TRUE, we hit the end of the file | 1396 int eof = FALSE; // if TRUE, we hit the end of the file |
1397 int didline = FALSE; // if TRUE, we finished the last line | 1397 int didline = FALSE; // if TRUE, we finished the last line |
1398 int i; | 1398 int i; |
1399 long j; | 1399 long j; |
1400 static int recursive = FALSE; // being called recursively | 1400 static int recursive = FALSE; // being called recursively |
1401 int old_botline = wp->w_botline; | 1401 linenr_T old_botline = wp->w_botline; |
1402 #ifdef FEAT_CONCEAL | |
1403 int old_wrow = wp->w_wrow; | |
1404 int old_wcol = wp->w_wcol; | |
1405 #endif | |
1402 #ifdef FEAT_FOLDING | 1406 #ifdef FEAT_FOLDING |
1403 long fold_count; | 1407 long fold_count; |
1404 #endif | 1408 #endif |
1405 #ifdef FEAT_SYN_HL | 1409 #ifdef FEAT_SYN_HL |
1406 // remember what happened to the previous line, to know if | 1410 // remember what happened to the previous line, to know if |
2565 // doesn't look too bad. Only do this for the current window (where | 2569 // doesn't look too bad. Only do this for the current window (where |
2566 // changes are relevant). | 2570 // changes are relevant). |
2567 wp->w_valid |= VALID_BOTLINE; | 2571 wp->w_valid |= VALID_BOTLINE; |
2568 if (wp == curwin && wp->w_botline != old_botline && !recursive) | 2572 if (wp == curwin && wp->w_botline != old_botline && !recursive) |
2569 { | 2573 { |
2574 win_T *wwp; | |
2575 #if defined(FEAT_CONCEAL) | |
2576 linenr_T old_topline = wp->w_topline; | |
2577 int new_wcol = wp->w_wcol; | |
2578 #endif | |
2570 recursive = TRUE; | 2579 recursive = TRUE; |
2571 curwin->w_valid &= ~VALID_TOPLINE; | 2580 curwin->w_valid &= ~VALID_TOPLINE; |
2572 update_topline(); // may invalidate w_botline again | 2581 update_topline(); // may invalidate w_botline again |
2573 if (must_redraw != 0) | 2582 |
2583 #if defined(FEAT_CONCEAL) | |
2584 if (old_wcol != new_wcol && (wp->w_valid & (VALID_WCOL|VALID_WROW)) | |
2585 != (VALID_WCOL|VALID_WROW)) | |
2586 { | |
2587 // A win_line() call applied a fix to screen cursor column to | |
2588 // accomodate concealment of cursor line, but in this call to | |
2589 // update_topline() the cursor's row or column got invalidated. | |
2590 // If they are left invalid, setcursor() will recompute them | |
2591 // but there won't be any further win_line() call to re-fix the | |
2592 // column and the cursor will end up misplaced. So we call | |
2593 // cursor validation now and reapply the fix again (or call | |
2594 // win_line() to do it for us). | |
2595 validate_cursor(); | |
2596 if (wp->w_wcol == old_wcol && wp->w_wrow == old_wrow | |
2597 && old_topline == wp->w_topline) | |
2598 wp->w_wcol = new_wcol; | |
2599 else | |
2600 redrawWinline(wp, wp->w_cursor.lnum); | |
2601 } | |
2602 #endif | |
2603 // New redraw either due to updated topline or due to wcol fix. | |
2604 if (wp->w_redr_type != 0) | |
2574 { | 2605 { |
2575 // Don't update for changes in buffer again. | 2606 // Don't update for changes in buffer again. |
2576 i = curbuf->b_mod_set; | 2607 i = curbuf->b_mod_set; |
2577 curbuf->b_mod_set = FALSE; | 2608 curbuf->b_mod_set = FALSE; |
2609 j = curbuf->b_mod_xlines; | |
2610 curbuf->b_mod_xlines = 0; | |
2578 win_update(curwin); | 2611 win_update(curwin); |
2579 must_redraw = 0; | |
2580 curbuf->b_mod_set = i; | 2612 curbuf->b_mod_set = i; |
2581 } | 2613 curbuf->b_mod_xlines = j; |
2614 } | |
2615 // Other windows might have w_redr_type raised in update_topline(). | |
2616 must_redraw = 0; | |
2617 FOR_ALL_WINDOWS(wwp) | |
2618 if (wwp->w_redr_type > must_redraw) | |
2619 must_redraw = wwp->w_redr_type; | |
2582 recursive = FALSE; | 2620 recursive = FALSE; |
2583 } | 2621 } |
2584 } | 2622 } |
2585 | 2623 |
2586 #if defined(FEAT_SYN_HL) || defined(FEAT_SEARCH_EXTRA) | 2624 #if defined(FEAT_SYN_HL) || defined(FEAT_SEARCH_EXTRA) |