comparison src/change.c @ 27754:1f37e5082343 v8.2.4403

patch 8.2.4403: ml_get error with nested folds and deleting lines Commit: https://github.com/vim/vim/commit/943773783384a5ff63f57769d37ddabf8156fe1e Author: Bram Moolenaar <Bram@vim.org> Date: Wed Feb 16 20:30:52 2022 +0000 patch 8.2.4403: ml_get error with nested folds and deleting lines Problem: ml_get error with nested folds and deleting lines. Solution: Correct the last line number before calling hasFoldingWin().
author Bram Moolenaar <Bram@vim.org>
date Wed, 16 Feb 2022 21:45:03 +0100
parents 17cd22b7151b
children 5a8258fde1d9
comparison
equal deleted inserted replaced
27753:30b81ad0e33f 27754:1f37e5082343
550 550
551 FOR_ALL_TAB_WINDOWS(tp, wp) 551 FOR_ALL_TAB_WINDOWS(tp, wp)
552 { 552 {
553 if (wp->w_buffer == curbuf) 553 if (wp->w_buffer == curbuf)
554 { 554 {
555 linenr_T last = lnume + xtra - 1; // last line after the change
556
555 // Mark this window to be redrawn later. 557 // Mark this window to be redrawn later.
556 if (wp->w_redr_type < VALID) 558 if (wp->w_redr_type < VALID)
557 wp->w_redr_type = VALID; 559 wp->w_redr_type = VALID;
558 560
559 // Check if a change in the buffer has invalidated the cached 561 // Check if a change in the buffer has invalidated the cached
560 // values for the cursor. 562 // values for the cursor.
561 #ifdef FEAT_FOLDING 563 #ifdef FEAT_FOLDING
562 // Update the folds for this window. Can't postpone this, because 564 // Update the folds for this window. Can't postpone this, because
563 // a following operator might work on the whole fold: ">>dd". 565 // a following operator might work on the whole fold: ">>dd".
564 foldUpdate(wp, lnum, lnume + xtra - 1); 566 foldUpdate(wp, lnum, last);
565 567
566 // The change may cause lines above or below the change to become 568 // The change may cause lines above or below the change to become
567 // included in a fold. Set lnum/lnume to the first/last line that 569 // included in a fold. Set lnum/lnume to the first/last line that
568 // might be displayed differently. 570 // might be displayed differently.
569 // Set w_cline_folded here as an efficient way to update it when 571 // Set w_cline_folded here as an efficient way to update it when
570 // inserting lines just above a closed fold. 572 // inserting lines just above a closed fold.
571 i = hasFoldingWin(wp, lnum, &lnum, NULL, FALSE, NULL); 573 i = hasFoldingWin(wp, lnum, &lnum, NULL, FALSE, NULL);
572 if (wp->w_cursor.lnum == lnum) 574 if (wp->w_cursor.lnum == lnum)
573 wp->w_cline_folded = i; 575 wp->w_cline_folded = i;
574 i = hasFoldingWin(wp, lnume, NULL, &lnume, FALSE, NULL); 576 i = hasFoldingWin(wp, last, NULL, &last, FALSE, NULL);
575 if (wp->w_cursor.lnum == lnume) 577 if (wp->w_cursor.lnum == last)
576 wp->w_cline_folded = i; 578 wp->w_cline_folded = i;
577 579
578 // If the changed line is in a range of previously folded lines, 580 // If the changed line is in a range of previously folded lines,
579 // compare with the first line in that range. 581 // compare with the first line in that range.
580 if (wp->w_cursor.lnum <= lnum) 582 if (wp->w_cursor.lnum <= lnum)