Skip to content

Instantly share code, notes, and snippets.

@knubie
Last active July 31, 2016 02:46
Show Gist options
  • Save knubie/ed71342c4504daba4f674d2f80a9c8b8 to your computer and use it in GitHub Desktop.
Save knubie/ed71342c4504daba4f674d2f80a9c8b8 to your computer and use it in GitHub Desktop.
Patch file for removing fold bug in vim
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index d83dc40..605b033 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -798,16 +798,6 @@ do_move(linenr_T line1, linenr_T line2, linenr_T dest)
linenr_T extra; /* Num lines added before line1 */
linenr_T num_lines; /* Num lines moved */
linenr_T last_line; /* Last line in file after adding new text */
-#ifdef FEAT_FOLDING
- int isFolded;
-
- /* Moving lines seems to corrupt the folds, delete folding info now
- * and recreate it when finished. Don't do this for manual folding, it
- * would delete all folds. */
- isFolded = hasAnyFolding(curwin) && !foldmethodIsManual(curwin);
- if (isFolded)
- deleteFoldRecurse(&curwin->w_folds);
-#endif
if (dest >= line1 && dest < line2)
{
@@ -906,12 +896,6 @@ do_move(linenr_T line1, linenr_T line2, linenr_T dest)
else
changed_lines(dest + 1, 0, line1 + num_lines, 0L);
-#ifdef FEAT_FOLDING
- /* recreate folds */
- if (isFolded)
- foldUpdateAll(curwin);
-#endif
-
return OK;
}
diff --git a/src/fold.c b/src/fold.c
index 8b9ca35..e856321 100644
--- a/src/fold.c
+++ b/src/fold.c
@@ -815,8 +815,8 @@ foldUpdate(win_T *wp, linenr_T top, linenr_T bot)
return;
/* Mark all folds from top to bot as maybe-small. */
- (void)foldFind(&wp->w_folds, top, &fp);
- while (fp < (fold_T *)wp->w_folds.ga_data + wp->w_folds.ga_len
+ (void)foldFind(&curwin->w_folds, top, &fp);
+ while (fp < (fold_T *)curwin->w_folds.ga_data + curwin->w_folds.ga_len
&& fp->fd_top < bot)
{
fp->fd_small = MAYBE;
diff --git a/src/testdir/test45.in b/src/testdir/test45.in
index b1e8266..e5af507 100644
--- a/src/testdir/test45.in
+++ b/src/testdir/test45.in
@@ -63,16 +63,6 @@ endfun
:call append("$", foldlevel("."))
:/^last/+1,$w! test.out
:delfun Flvl
-:new
-iTest fdm=indent and :move bug END
-line2
- Test fdm=indent START
- line3
- line4
-:set fdm=indent
-:1m1
-2jzc:m0
-:%w >> test.out
:qa!
ENDTEST
diff --git a/src/testdir/test45.ok b/src/testdir/test45.ok
index 0f25e62..f04996e 100644
--- a/src/testdir/test45.ok
+++ b/src/testdir/test45.ok
@@ -16,8 +16,3 @@ expr 2
1
2
0
- Test fdm=indent START
- line3
- line4
-Test fdm=indent and :move bug END
-line2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment