]> git.ipfire.org Git - ipfire-3.x.git/blame - vim/patches/vim-7.3.462.patch0
vim: Import latest patches from upstream.
[ipfire-3.x.git] / vim / patches / vim-7.3.462.patch0
CommitLineData
c6060300
MT
1To: vim_dev@googlegroups.com
2Subject: Patch 7.3.462
3Fcc: outbox
4From: Bram Moolenaar <Bram@moolenaar.net>
5Mime-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8------------
9
10Patch 7.3.462
11Problem: When using ":loadview" folds may be closed unexpectedly.
12Solution: Take into account foldlevel. (Xavier de Gaye)
13Files: src/fold.c
14
15
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
18***************
19*** 3292,3298 ****
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));
24
25 /*
26 * Write commands to "fd" to restore the manual folds in window "wp".
27--- 3292,3299 ----
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));
33
34 /*
35 * Write commands to "fd" to restore the manual folds in window "wp".
36***************
37*** 3312,3318 ****
38
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);
42
43 return OK;
44 }
45--- 3313,3319 ----
46
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);
50
51 return OK;
52 }
53***************
54*** 3352,3363 ****
55 * Returns FAIL when writing failed.
56 */
57 static int
58! put_foldopen_recurse(fd, gap, off)
59 FILE *fd;
60 garray_T *gap;
61 linenr_T off;
62 {
63 int i;
64 fold_T *fp;
65
66 fp = (fold_T *)gap->ga_data;
67--- 3353,3366 ----
68 * Returns FAIL when writing failed.
69 */
70 static int
71! put_foldopen_recurse(fd, wp, gap, off)
72 FILE *fd;
73+ win_T *wp;
74 garray_T *gap;
75 linenr_T off;
76 {
77 int i;
78+ int level;
79 fold_T *fp;
80
81 fp = (fold_T *)gap->ga_data;
82***************
83*** 3367,3393 ****
84 {
85 if (fp->fd_nested.ga_len > 0)
86 {
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)
91 return FAIL;
92! if (put_foldopen_recurse(fd, &fp->fd_nested, off + fp->fd_top)
93 == FAIL)
94 return FAIL;
95 }
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)
101- return FAIL;
102 }
103 ++fp;
104 }
105
106 return OK;
107 }
108 #endif /* FEAT_SESSION */
109
110 /* }}}1 */
111--- 3370,3429 ----
112 {
113 if (fp->fd_nested.ga_len > 0)
114 {
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)
119 return FAIL;
120! if (put_foldopen_recurse(fd, wp, &fp->fd_nested,
121! off + fp->fd_top)
122 == FAIL)
123 return FAIL;
124+ /* close the parent when needed */
125+ if (fp->fd_flags == FD_CLOSED)
126+ {
127+ if (put_fold_open_close(fd, fp, off) == FAIL)
128+ return FAIL;
129+ }
130+ }
131+ else
132+ {
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
135+ * the parent. */
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)
140+ return FAIL;
141 }
142 }
143 ++fp;
144 }
145
146 return OK;
147 }
148+
149+ /* put_fold_open_close() {{{2 */
150+ /*
151+ * Write the open or close command to "fd".
152+ * Returns FAIL when writing failed.
153+ */
154+ static int
155+ put_fold_open_close(fd, fp, off)
156+ FILE *fd;
157+ fold_T *fp;
158+ linenr_T off;
159+ {
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)
165+ return FAIL;
166+
167+ return OK;
168+ }
169 #endif /* FEAT_SESSION */
170
171 /* }}}1 */
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
174***************
175*** 716,717 ****
176--- 716,719 ----
177 { /* Add new patch number below this line */
178+ /**/
179+ 462,
180 /**/
181
182--
183~
184~
185~
186".signature" 4 lines, 50 characters written
187
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 ///