Problem:
In certain circumstances folds get messed up if a file that is edited in
the not-current tab is modified from outside of Vim.

Steps to reproduce:
In Vim open two files with the following contents:

file1.txt:
#v+
line1
line2 [[[
line3
line4
line5
line6 ]]]

vim: fdm=marker fmr=[[[,]]] fdc=3
#v-

file2.txt:
#v+
 line1 [[[
 line2
 line3 ]]]
 line4 [[[
 line5
 line6 ]]]

vim: fdm=indent sw=1 fdc=3
#v-

$ vim -p file1.txt file2.txt

The fold column in the first tab shows one fold: <2,6>.
>From outside of Vim modify the change time of file2.txt:
$ touch file2.txt

In Vim:
:checktime

Although file1.txt has not been modified, the fold column in the first
tab shows two folds: <1,3> and <4,6>,

Solution:
Restore folds after reading the file identified to have been modified.

-- 
Cheers,
Lech

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

diff --git a/src/fileio.c b/src/fileio.c
index d190863..678277e 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -8432,6 +8432,8 @@ aucmd_prepbuf(aco, buf)
 	aco->save_topfill = curwin->w_topfill;
 	curwin->w_topfill = 0;
 #endif
+	aco->save_folds = curwin->w_folds;
+	ga_init(&curwin->w_folds);
     }
 
     curbuf = buf;
@@ -8495,6 +8497,8 @@ aucmd_restbuf(aco)
 		curwin->w_topfill = 0;
 #endif
 	    }
+	    ga_clear(&curwin->w_folds);
+	    curwin->w_folds = aco->save_folds;
 	}
     }
 }
diff --git a/src/structs.h b/src/structs.h
index 95b5e62..3bad2e8 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -2285,6 +2285,7 @@ typedef struct
     linenr_T	save_topline;	/* saved topline of save_curwin */
 # ifdef FEAT_DIFF
     int		save_topfill;	/* saved topfill of save_curwin */
+    garray_T	save_folds;	/* array of folds saved for curwin */
 # endif
 #endif
 } aco_save_T;

Raspunde prin e-mail lui