@@ -851,24 +851,41 @@ do_move(linenr_T line1, linenr_T line2, linenr_T dest)
851851 * their final destination at the new text position -- webb
852852 */
853853 last_line = curbuf -> b_ml .ml_line_count ;
854- mark_adjust (line1 , line2 , last_line - line2 , 0L );
855- changed_lines (last_line - num_lines + 1 , 0 , last_line + 1 , num_lines );
854+ mark_adjust_nofold (line1 , line2 , last_line - line2 , 0L );
856855 if (dest >= line2 )
857856 {
858- mark_adjust (line2 + 1 , dest , - num_lines , 0L );
857+ mark_adjust_nofold (line2 + 1 , dest , - num_lines , 0L );
858+ #ifdef FEAT_FOLDING
859+ win_T * win ;
860+ tabpage_T * tp ;
861+
862+ FOR_ALL_TAB_WINDOWS (tp , win ) {
863+ if (win -> w_buffer == curbuf )
864+ foldSwapRange (& win -> w_folds , line1 , line2 , dest + 1 ,
865+ dest + num_lines );
866+ }
867+ #endif
859868 curbuf -> b_op_start .lnum = dest - num_lines + 1 ;
860869 curbuf -> b_op_end .lnum = dest ;
861870 }
862871 else
863872 {
864- mark_adjust (dest + 1 , line1 - 1 , num_lines , 0L );
873+ mark_adjust_nofold (dest + 1 , line1 - 1 , num_lines , 0L );
874+ #ifdef FEAT_FOLDING
875+ win_T * win ;
876+ tabpage_T * tp ;
877+
878+ FOR_ALL_TAB_WINDOWS (tp , win ) {
879+ if (win -> w_buffer == curbuf )
880+ foldSwapRange (& win -> w_folds , dest + 1 , line1 - 1 , line1 , line2 );
881+ }
882+ #endif
865883 curbuf -> b_op_start .lnum = dest + 1 ;
866884 curbuf -> b_op_end .lnum = dest + num_lines ;
867885 }
868886 curbuf -> b_op_start .col = curbuf -> b_op_end .col = 0 ;
869- mark_adjust (last_line - num_lines + 1 , last_line ,
887+ mark_adjust_nofold (last_line - num_lines + 1 , last_line ,
870888 - (last_line - dest - extra ), 0L );
871- changed_lines (last_line - num_lines + 1 , 0 , last_line + 1 , - extra );
872889
873890 /*
874891 * Now we delete the original text -- webb
@@ -4211,7 +4228,7 @@ do_ecmd(
42114228
42124229 /* If autocommands change the cursor position or topline, we should
42134230 * keep it. Also when it moves within a line. */
4214- if (!equalpos (curwin -> w_cursor , orig_pos ))
4231+ if (!EQUAL_POS (curwin -> w_cursor , orig_pos ))
42154232 {
42164233 newlnum = curwin -> w_cursor .lnum ;
42174234 newcol = curwin -> w_cursor .col ;
0 commit comments