1 To: vim_dev@googlegroups.com
4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
11 Problem: When using ":loadview" folds may be closed unexpectedly.
12 Solution: Take into account foldlevel. (Xavier de Gaye)
16 *** ../vim-7.3.461/src/fold.c 2012-01-10 22:26:12.000000000 +0100
17 --- src/fold.c 2012-02-29 19:18:07.000000000 +0100
20 /* put_folds() {{{2 */
21 #if defined(FEAT_SESSION) || defined(PROTO)
22 static int put_folds_recurse __ARGS((FILE *fd, garray_T *gap, linenr_T off));
23 ! static int put_foldopen_recurse __ARGS((FILE *fd, garray_T *gap, linenr_T off));
26 * Write commands to "fd" to restore the manual folds in window "wp".
28 /* put_folds() {{{2 */
29 #if defined(FEAT_SESSION) || defined(PROTO)
30 static int put_folds_recurse __ARGS((FILE *fd, garray_T *gap, linenr_T off));
31 ! static int put_foldopen_recurse __ARGS((FILE *fd, win_T *wp, garray_T *gap, linenr_T off));
32 ! static int put_fold_open_close __ARGS((FILE *fd, fold_T *fp, linenr_T off));
35 * Write commands to "fd" to restore the manual folds in window "wp".
39 /* If some folds are manually opened/closed, need to restore that. */
40 if (wp->w_fold_manual)
41 ! return put_foldopen_recurse(fd, &wp->w_folds, (linenr_T)0);
47 /* If some folds are manually opened/closed, need to restore that. */
48 if (wp->w_fold_manual)
49 ! return put_foldopen_recurse(fd, wp, &wp->w_folds, (linenr_T)0);
55 * Returns FAIL when writing failed.
58 ! put_foldopen_recurse(fd, gap, off)
66 fp = (fold_T *)gap->ga_data;
68 * Returns FAIL when writing failed.
71 ! put_foldopen_recurse(fd, wp, gap, off)
81 fp = (fold_T *)gap->ga_data;
85 if (fp->fd_nested.ga_len > 0)
87 ! /* open/close nested folds while this fold is open */
88 if (fprintf(fd, "%ld", fp->fd_top + off) < 0
89 || put_eol(fd) == FAIL
90 || put_line(fd, "normal zo") == FAIL)
92 ! if (put_foldopen_recurse(fd, &fp->fd_nested, off + fp->fd_top)
96 - if (fprintf(fd, "%ld", fp->fd_top + off) < 0
97 - || put_eol(fd) == FAIL
98 - || fprintf(fd, "normal z%c",
99 - fp->fd_flags == FD_CLOSED ? 'c' : 'o') < 0
100 - || put_eol(fd) == FAIL)
108 #endif /* FEAT_SESSION */
113 if (fp->fd_nested.ga_len > 0)
115 ! /* open nested folds while this fold is open */
116 if (fprintf(fd, "%ld", fp->fd_top + off) < 0
117 || put_eol(fd) == FAIL
118 || put_line(fd, "normal zo") == FAIL)
120 ! if (put_foldopen_recurse(fd, wp, &fp->fd_nested,
124 + /* close the parent when needed */
125 + if (fp->fd_flags == FD_CLOSED)
127 + if (put_fold_open_close(fd, fp, off) == FAIL)
133 + /* Open or close the leaf according to the window foldlevel.
134 + * Do not close a leaf that is already closed, as it will close
136 + level = foldLevelWin(wp, off + fp->fd_top);
137 + if ((fp->fd_flags == FD_CLOSED && wp->w_p_fdl >= level)
138 + || (fp->fd_flags != FD_CLOSED && wp->w_p_fdl < level))
139 + if (put_fold_open_close(fd, fp, off) == FAIL)
149 + /* put_fold_open_close() {{{2 */
151 + * Write the open or close command to "fd".
152 + * Returns FAIL when writing failed.
155 + put_fold_open_close(fd, fp, off)
160 + if (fprintf(fd, "%ld", fp->fd_top + off) < 0
161 + || put_eol(fd) == FAIL
162 + || fprintf(fd, "normal z%c",
163 + fp->fd_flags == FD_CLOSED ? 'c' : 'o') < 0
164 + || put_eol(fd) == FAIL)
169 #endif /* FEAT_SESSION */
172 *** ../vim-7.3.461/src/version.c 2012-02-29 18:22:03.000000000 +0100
173 --- src/version.c 2012-02-29 18:40:43.000000000 +0100
177 { /* Add new patch number below this line */
186 ".signature" 4 lines, 50 characters written
188 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
189 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
190 \\\ an exciting new programming language -- http://www.Zimbu.org ///
191 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///