Merge pull request #12996 from teto/foldcol

folds: pass column on fold creation
This commit is contained in:
Thomas Vigouroux 2020-09-29 06:40:10 +02:00 committed by GitHub
commit 090551a802
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 142 additions and 110 deletions

View File

@ -837,7 +837,7 @@ static void clear_wininfo(buf_T *buf)
buf->b_wininfo = wip->wi_next; buf->b_wininfo = wip->wi_next;
if (wip->wi_optset) { if (wip->wi_optset) {
clear_winopt(&wip->wi_opt); clear_winopt(&wip->wi_opt);
deleteFoldRecurse(&wip->wi_folds); deleteFoldRecurse(buf, &wip->wi_folds);
} }
xfree(wip); xfree(wip);
} }
@ -2503,7 +2503,7 @@ void buflist_setfpos(buf_T *const buf, win_T *const win,
} }
if (copy_options && wip->wi_optset) { if (copy_options && wip->wi_optset) {
clear_winopt(&wip->wi_opt); clear_winopt(&wip->wi_opt);
deleteFoldRecurse(&wip->wi_folds); deleteFoldRecurse(buf, &wip->wi_folds);
} }
} }
if (lnum != 0) { if (lnum != 0) {

View File

@ -9297,14 +9297,17 @@ static void ex_match(exarg_T *eap)
static void ex_fold(exarg_T *eap) static void ex_fold(exarg_T *eap)
{ {
if (foldManualAllowed(true)) { if (foldManualAllowed(true)) {
foldCreate(curwin, eap->line1, eap->line2); pos_T start = { eap->line1, 1, 0 };
pos_T end = { eap->line2, 1, 0 };
foldCreate(curwin, start, end);
} }
} }
static void ex_foldopen(exarg_T *eap) static void ex_foldopen(exarg_T *eap)
{ {
opFoldRange(eap->line1, eap->line2, eap->cmdidx == CMD_foldopen, pos_T start = { eap->line1, 1, 0 };
eap->forceit, FALSE); pos_T end = { eap->line2, 1, 0 };
opFoldRange(start, end, eap->cmdidx == CMD_foldopen, eap->forceit, false);
} }
static void ex_folddo(exarg_T *eap) static void ex_folddo(exarg_T *eap)

View File

@ -153,14 +153,22 @@ bool hasFolding(linenr_T lnum, linenr_T *firstp, linenr_T *lastp)
return hasFoldingWin(curwin, lnum, firstp, lastp, true, NULL); return hasFoldingWin(curwin, lnum, firstp, lastp, true, NULL);
} }
/* hasFoldingWin() {{{2 */ // hasFoldingWin() {{{2
/// Search folds starting at lnum
/// @param lnum first line to search
/// @param[out] first first line of fold containing lnum
/// @param[out] lastp last line with a fold
/// @param cache when true: use cached values of window
/// @param[out] infop where to store fold info
///
/// @return true if range contains folds
bool hasFoldingWin( bool hasFoldingWin(
win_T *const win, win_T *const win,
const linenr_T lnum, const linenr_T lnum,
linenr_T *const firstp, linenr_T *const firstp,
linenr_T *const lastp, linenr_T *const lastp,
const bool cache, // when true: use cached values of window const bool cache,
foldinfo_T *const infop // where to store fold info foldinfo_T *const infop
) )
{ {
bool had_folded = false; bool had_folded = false;
@ -361,23 +369,21 @@ int foldmethodIsDiff(win_T *wp)
return wp->w_p_fdm[0] == 'd'; return wp->w_p_fdm[0] == 'd';
} }
/* closeFold() {{{2 */ // closeFold() {{{2
/* /// Close fold for current window at line "lnum".
* Close fold for current window at line "lnum". /// Repeat "count" times.
* Repeat "count" times. void closeFold(pos_T pos, long count)
*/
void closeFold(linenr_T lnum, long count)
{ {
setFoldRepeat(lnum, count, FALSE); setFoldRepeat(pos, count, false);
} }
/* closeFoldRecurse() {{{2 */ /* closeFoldRecurse() {{{2 */
/* /*
* Close fold for current window at line "lnum" recursively. * Close fold for current window at line "lnum" recursively.
*/ */
void closeFoldRecurse(linenr_T lnum) void closeFoldRecurse(pos_T pos)
{ {
(void)setManualFold(lnum, FALSE, TRUE, NULL); (void)setManualFold(pos, false, true, NULL);
} }
/* opFoldRange() {{{2 */ /* opFoldRange() {{{2 */
@ -387,28 +393,32 @@ void closeFoldRecurse(linenr_T lnum)
*/ */
void void
opFoldRange( opFoldRange(
linenr_T first, pos_T firstpos,
linenr_T last, pos_T lastpos,
int opening, // TRUE to open, FALSE to close int opening, // TRUE to open, FALSE to close
int recurse, // TRUE to do it recursively int recurse, // TRUE to do it recursively
int had_visual // TRUE when Visual selection used int had_visual // TRUE when Visual selection used
) )
{ {
int done = DONE_NOTHING; /* avoid error messages */ int done = DONE_NOTHING; // avoid error messages
linenr_T first = firstpos.lnum;
linenr_T last = lastpos.lnum;
linenr_T lnum; linenr_T lnum;
linenr_T lnum_next; linenr_T lnum_next;
for (lnum = first; lnum <= last; lnum = lnum_next + 1) { for (lnum = first; lnum <= last; lnum = lnum_next + 1) {
pos_T temp = { lnum, 0, 0 };
lnum_next = lnum; lnum_next = lnum;
/* Opening one level only: next fold to open is after the one going to /* Opening one level only: next fold to open is after the one going to
* be opened. */ * be opened. */
if (opening && !recurse) if (opening && !recurse)
(void)hasFolding(lnum, NULL, &lnum_next); (void)hasFolding(lnum, NULL, &lnum_next);
(void)setManualFold(lnum, opening, recurse, &done); (void)setManualFold(temp, opening, recurse, &done);
/* Closing one level only: next line to close a fold is after just // Closing one level only: next line to close a fold is after just
* closed fold. */ // closed fold.
if (!opening && !recurse) if (!opening && !recurse) {
(void)hasFolding(lnum, NULL, &lnum_next); (void)hasFolding(lnum, NULL, &lnum_next);
}
} }
if (done == DONE_NOTHING) if (done == DONE_NOTHING)
EMSG(_(e_nofold)); EMSG(_(e_nofold));
@ -422,18 +432,18 @@ opFoldRange(
* Open fold for current window at line "lnum". * Open fold for current window at line "lnum".
* Repeat "count" times. * Repeat "count" times.
*/ */
void openFold(linenr_T lnum, long count) void openFold(pos_T pos, long count)
{ {
setFoldRepeat(lnum, count, TRUE); setFoldRepeat(pos, count, true);
} }
/* openFoldRecurse() {{{2 */ /* openFoldRecurse() {{{2 */
/* /*
* Open fold for current window at line "lnum" recursively. * Open fold for current window at line "lnum" recursively.
*/ */
void openFoldRecurse(linenr_T lnum) void openFoldRecurse(pos_T pos)
{ {
(void)setManualFold(lnum, TRUE, TRUE, NULL); (void)setManualFold(pos, true, true, NULL);
} }
/* foldOpenCursor() {{{2 */ /* foldOpenCursor() {{{2 */
@ -448,9 +458,10 @@ void foldOpenCursor(void)
if (hasAnyFolding(curwin)) if (hasAnyFolding(curwin))
for (;; ) { for (;; ) {
done = DONE_NOTHING; done = DONE_NOTHING;
(void)setManualFold(curwin->w_cursor.lnum, TRUE, FALSE, &done); (void)setManualFold(curwin->w_cursor, true, false, &done);
if (!(done & DONE_ACTION)) if (!(done & DONE_ACTION)) {
break; break;
}
} }
} }
@ -547,21 +558,21 @@ int foldManualAllowed(int create)
// foldCreate() {{{2 // foldCreate() {{{2
/// Create a fold from line "start" to line "end" (inclusive) in the current /// Create a fold from line "start" to line "end" (inclusive) in the current
/// window. /// window.
void foldCreate(win_T *wp, linenr_T start, linenr_T end) void foldCreate(win_T *wp, pos_T start, pos_T end)
{ {
fold_T *fp; fold_T *fp;
garray_T *gap; garray_T *gap;
garray_T fold_ga; garray_T fold_ga;
int i, j; int i;
int cont; int cont;
int use_level = FALSE; int use_level = FALSE;
int closed = FALSE; int closed = FALSE;
int level = 0; int level = 0;
linenr_T start_rel = start; pos_T start_rel = start;
linenr_T end_rel = end; pos_T end_rel = end;
if (start > end) { if (start.lnum > end.lnum) {
/* reverse the range */ // reverse the range
end = start_rel; end = start_rel;
start = end_rel; start = end_rel;
start_rel = start; start_rel = start;
@ -582,14 +593,14 @@ void foldCreate(win_T *wp, linenr_T start, linenr_T end)
i = 0; i = 0;
} else { } else {
for (;;) { for (;;) {
if (!foldFind(gap, start_rel, &fp)) { if (!foldFind(gap, start_rel.lnum, &fp)) {
break; break;
} }
if (fp->fd_top + fp->fd_len > end_rel) { if (fp->fd_top + fp->fd_len > end_rel.lnum) {
// New fold is completely inside this fold: Go one level deeper. // New fold is completely inside this fold: Go one level deeper.
gap = &fp->fd_nested; gap = &fp->fd_nested;
start_rel -= fp->fd_top; start_rel.lnum -= fp->fd_top;
end_rel -= fp->fd_top; end_rel.lnum -= fp->fd_top;
if (use_level || fp->fd_flags == FD_LEVEL) { if (use_level || fp->fd_flags == FD_LEVEL) {
use_level = true; use_level = true;
if (level >= wp->w_p_fdl) { if (level >= wp->w_p_fdl) {
@ -613,30 +624,35 @@ void foldCreate(win_T *wp, linenr_T start, linenr_T end)
fp = (fold_T *)gap->ga_data + i; fp = (fold_T *)gap->ga_data + i;
ga_init(&fold_ga, (int)sizeof(fold_T), 10); ga_init(&fold_ga, (int)sizeof(fold_T), 10);
/* Count number of folds that will be contained in the new fold. */ // Count number of folds that will be contained in the new fold.
for (cont = 0; i + cont < gap->ga_len; ++cont) for (cont = 0; i + cont < gap->ga_len; cont++) {
if (fp[cont].fd_top > end_rel) if (fp[cont].fd_top > end_rel.lnum) {
break; break;
}
}
if (cont > 0) { if (cont > 0) {
ga_grow(&fold_ga, cont); ga_grow(&fold_ga, cont);
/* If the first fold starts before the new fold, let the new fold /* If the first fold starts before the new fold, let the new fold
* start there. Otherwise the existing fold would change. */ * start there. Otherwise the existing fold would change. */
if (start_rel > fp->fd_top) if (start_rel.lnum > fp->fd_top) {
start_rel = fp->fd_top; start_rel.lnum = fp->fd_top;
}
/* When last contained fold isn't completely contained, adjust end // When last contained fold isn't completely contained, adjust end
* of new fold. */ // of new fold.
if (end_rel < fp[cont - 1].fd_top + fp[cont - 1].fd_len - 1) if (end_rel.lnum < fp[cont - 1].fd_top + fp[cont - 1].fd_len - 1) {
end_rel = fp[cont - 1].fd_top + fp[cont - 1].fd_len - 1; end_rel.lnum = fp[cont - 1].fd_top + fp[cont - 1].fd_len - 1;
/* Move contained folds to inside new fold. */ }
// Move contained folds to inside new fold
memmove(fold_ga.ga_data, fp, sizeof(fold_T) * (size_t)cont); memmove(fold_ga.ga_data, fp, sizeof(fold_T) * (size_t)cont);
fold_ga.ga_len += cont; fold_ga.ga_len += cont;
i += cont; i += cont;
/* Adjust line numbers in contained folds to be relative to the /* Adjust line numbers in contained folds to be relative to the
* new fold. */ * new fold. */
for (j = 0; j < cont; ++j) for (int j = 0; j < cont; j++) {
((fold_T *)fold_ga.ga_data)[j].fd_top -= start_rel; ((fold_T *)fold_ga.ga_data)[j].fd_top -= start_rel.lnum;
}
} }
/* Move remaining entries to after the new fold. */ /* Move remaining entries to after the new fold. */
if (i < gap->ga_len) if (i < gap->ga_len)
@ -646,8 +662,8 @@ void foldCreate(win_T *wp, linenr_T start, linenr_T end)
/* insert new fold */ /* insert new fold */
fp->fd_nested = fold_ga; fp->fd_nested = fold_ga;
fp->fd_top = start_rel; fp->fd_top = start_rel.lnum;
fp->fd_len = end_rel - start_rel + 1; fp->fd_len = end_rel.lnum - start_rel.lnum + 1;
/* We want the new fold to be closed. If it would remain open because /* We want the new fold to be closed. If it would remain open because
* of using 'foldlevel', need to adjust fd_flags of containing folds. * of using 'foldlevel', need to adjust fd_flags of containing folds.
@ -776,7 +792,7 @@ void deleteFold(
*/ */
void clearFolding(win_T *win) void clearFolding(win_T *win)
{ {
deleteFoldRecurse(&win->w_folds); deleteFoldRecurse(win->w_buffer, &win->w_folds);
win->w_foldinvalid = false; win->w_foldinvalid = false;
} }
@ -1148,14 +1164,14 @@ static void checkupdate(win_T *wp)
* Open or close fold for current window at line "lnum". * Open or close fold for current window at line "lnum".
* Repeat "count" times. * Repeat "count" times.
*/ */
static void setFoldRepeat(linenr_T lnum, long count, int do_open) static void setFoldRepeat(pos_T pos, long count, int do_open)
{ {
int done; int done;
long n; long n;
for (n = 0; n < count; ++n) { for (n = 0; n < count; ++n) {
done = DONE_NOTHING; done = DONE_NOTHING;
(void)setManualFold(lnum, do_open, FALSE, &done); (void)setManualFold(pos, do_open, false, &done);
if (!(done & DONE_ACTION)) { if (!(done & DONE_ACTION)) {
/* Only give an error message when no fold could be opened. */ /* Only give an error message when no fold could be opened. */
if (n == 0 && !(done & DONE_FOLD)) if (n == 0 && !(done & DONE_FOLD))
@ -1172,12 +1188,13 @@ static void setFoldRepeat(linenr_T lnum, long count, int do_open)
*/ */
static linenr_T static linenr_T
setManualFold( setManualFold(
linenr_T lnum, pos_T pos,
int opening, // TRUE when opening, FALSE when closing int opening, // TRUE when opening, FALSE when closing
int recurse, // TRUE when closing/opening recursive int recurse, // TRUE when closing/opening recursive
int *donep int *donep
) )
{ {
linenr_T lnum = pos.lnum;
if (foldmethodIsDiff(curwin) && curwin->w_p_scb) { if (foldmethodIsDiff(curwin) && curwin->w_p_scb) {
linenr_T dlnum; linenr_T dlnum;
@ -1331,7 +1348,7 @@ static void deleteFoldEntry(win_T *const wp, garray_T *const gap, const int idx,
fold_T *fp = (fold_T *)gap->ga_data + idx; fold_T *fp = (fold_T *)gap->ga_data + idx;
if (recursive || GA_EMPTY(&fp->fd_nested)) { if (recursive || GA_EMPTY(&fp->fd_nested)) {
// recursively delete the contained folds // recursively delete the contained folds
deleteFoldRecurse(&fp->fd_nested); deleteFoldRecurse(wp->w_buffer, &fp->fd_nested);
gap->ga_len--; gap->ga_len--;
if (idx < gap->ga_len) { if (idx < gap->ga_len) {
memmove(fp, fp + 1, sizeof(*fp) * (size_t)(gap->ga_len - idx)); memmove(fp, fp + 1, sizeof(*fp) * (size_t)(gap->ga_len - idx));
@ -1373,9 +1390,9 @@ static void deleteFoldEntry(win_T *const wp, garray_T *const gap, const int idx,
/* /*
* Delete nested folds in a fold. * Delete nested folds in a fold.
*/ */
void deleteFoldRecurse(garray_T *gap) void deleteFoldRecurse(buf_T *bp, garray_T *gap)
{ {
# define DELETE_FOLD_NESTED(fd) deleteFoldRecurse(&((fd)->fd_nested)) # define DELETE_FOLD_NESTED(fd) deleteFoldRecurse(bp, &((fd)->fd_nested))
GA_DEEP_CLEAR(gap, fold_T, DELETE_FOLD_NESTED); GA_DEEP_CLEAR(gap, fold_T, DELETE_FOLD_NESTED);
} }
@ -1615,7 +1632,7 @@ static void setSmallMaybe(garray_T *gap)
* Create a fold from line "start" to line "end" (inclusive) in the current * Create a fold from line "start" to line "end" (inclusive) in the current
* window by adding markers. * window by adding markers.
*/ */
static void foldCreateMarkers(win_T *wp, linenr_T start, linenr_T end) static void foldCreateMarkers(win_T *wp, pos_T start, pos_T end)
{ {
buf_T *buf = wp->w_buffer; buf_T *buf = wp->w_buffer;
if (!MODIFIABLE(buf)) { if (!MODIFIABLE(buf)) {
@ -1630,13 +1647,13 @@ static void foldCreateMarkers(win_T *wp, linenr_T start, linenr_T end)
/* Update both changes here, to avoid all folds after the start are /* Update both changes here, to avoid all folds after the start are
* changed when the start marker is inserted and the end isn't. */ * changed when the start marker is inserted and the end isn't. */
// TODO(teto): pass the buffer // TODO(teto): pass the buffer
changed_lines(start, (colnr_T)0, end, 0L, false); changed_lines(start.lnum, (colnr_T)0, end.lnum, 0L, false);
// Note: foldAddMarker() may not actually change start and/or end if // Note: foldAddMarker() may not actually change start and/or end if
// u_save() is unable to save the buffer line, but we send the // u_save() is unable to save the buffer line, but we send the
// nvim_buf_lines_event anyway since it won't do any harm. // nvim_buf_lines_event anyway since it won't do any harm.
int64_t num_changed = 1 + end - start; int64_t num_changed = 1 + end.lnum - start.lnum;
buf_updates_send_changes(buf, start, num_changed, num_changed, true); buf_updates_send_changes(buf, start.lnum, num_changed, num_changed, true);
} }
/* foldAddMarker() {{{2 */ /* foldAddMarker() {{{2 */
@ -1644,13 +1661,14 @@ static void foldCreateMarkers(win_T *wp, linenr_T start, linenr_T end)
* Add "marker[markerlen]" in 'commentstring' to line "lnum". * Add "marker[markerlen]" in 'commentstring' to line "lnum".
*/ */
static void foldAddMarker( static void foldAddMarker(
buf_T *buf, linenr_T lnum, const char_u *marker, size_t markerlen) buf_T *buf, pos_T pos, const char_u *marker, size_t markerlen)
{ {
char_u *cms = buf->b_p_cms; char_u *cms = buf->b_p_cms;
char_u *line; char_u *line;
char_u *newline; char_u *newline;
char_u *p = (char_u *)strstr((char *)buf->b_p_cms, "%s"); char_u *p = (char_u *)strstr((char *)buf->b_p_cms, "%s");
bool line_is_comment = false; bool line_is_comment = false;
linenr_T lnum = pos.lnum;
// Allocate a new line: old-line + 'cms'-start + marker + 'cms'-end // Allocate a new line: old-line + 'cms'-start + marker + 'cms'-end
line = ml_get_buf(buf, lnum, false); line = ml_get_buf(buf, lnum, false);
@ -1756,8 +1774,13 @@ static void foldDelMarker(
} }
// get_foldtext() {{{2 // get_foldtext() {{{2
/// Return the text for a closed fold at line "lnum", with last line "lnume". /// Generates text to display
/// When 'foldtext' isn't set puts the result in "buf[FOLD_TEXT_LEN]". ///
/// @param buf allocated memory of length FOLD_TEXT_LEN. Used when 'foldtext'
/// isn't set puts the result in "buf[FOLD_TEXT_LEN]".
/// @param at line "lnum", with last line "lnume".
/// @return the text for a closed fold
///
/// Otherwise the result is in allocated memory. /// Otherwise the result is in allocated memory.
char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume, char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume,
foldinfo_T foldinfo, char_u *buf) foldinfo_T foldinfo, char_u *buf)

View File

@ -1977,20 +1977,20 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
case OP_FOLD: case OP_FOLD:
VIsual_reselect = false; // don't reselect now VIsual_reselect = false; // don't reselect now
foldCreate(curwin, oap->start.lnum, oap->end.lnum); foldCreate(curwin, oap->start, oap->end);
break; break;
case OP_FOLDOPEN: case OP_FOLDOPEN:
case OP_FOLDOPENREC: case OP_FOLDOPENREC:
case OP_FOLDCLOSE: case OP_FOLDCLOSE:
case OP_FOLDCLOSEREC: case OP_FOLDCLOSEREC:
VIsual_reselect = false; /* don't reselect now */ VIsual_reselect = false; // don't reselect now
opFoldRange(oap->start.lnum, oap->end.lnum, opFoldRange(oap->start, oap->end,
oap->op_type == OP_FOLDOPEN oap->op_type == OP_FOLDOPEN
|| oap->op_type == OP_FOLDOPENREC, || oap->op_type == OP_FOLDOPENREC,
oap->op_type == OP_FOLDOPENREC oap->op_type == OP_FOLDOPENREC
|| oap->op_type == OP_FOLDCLOSEREC, || oap->op_type == OP_FOLDCLOSEREC,
oap->is_VIsual); oap->is_VIsual);
break; break;
case OP_FOLDDEL: case OP_FOLDDEL:
@ -2590,14 +2590,16 @@ do_mouse (
&& !is_drag && !is_drag
&& (jump_flags & (MOUSE_FOLD_CLOSE | MOUSE_FOLD_OPEN)) && (jump_flags & (MOUSE_FOLD_CLOSE | MOUSE_FOLD_OPEN))
&& which_button == MOUSE_LEFT) { && which_button == MOUSE_LEFT) {
/* open or close a fold at this line */ // open or close a fold at this line
if (jump_flags & MOUSE_FOLD_OPEN) if (jump_flags & MOUSE_FOLD_OPEN) {
openFold(curwin->w_cursor.lnum, 1L); openFold(curwin->w_cursor, 1L);
else } else {
closeFold(curwin->w_cursor.lnum, 1L); closeFold(curwin->w_cursor, 1L);
/* don't move the cursor if still in the same window */ }
if (curwin == old_curwin) // don't move the cursor if still in the same window
if (curwin == old_curwin) {
curwin->w_cursor = save_cursor; curwin->w_cursor = save_cursor;
}
} }
@ -4393,51 +4395,55 @@ dozet:
case 'i': curwin->w_p_fen = !curwin->w_p_fen; case 'i': curwin->w_p_fen = !curwin->w_p_fen;
break; break;
/* "za": open closed fold or close open fold at cursor */ // "za": open closed fold or close open fold at cursor
case 'a': if (hasFolding(curwin->w_cursor.lnum, NULL, NULL)) case 'a': if (hasFolding(curwin->w_cursor.lnum, NULL, NULL)) {
openFold(curwin->w_cursor.lnum, cap->count1); openFold(curwin->w_cursor, cap->count1);
else { } else {
closeFold(curwin->w_cursor.lnum, cap->count1); closeFold(curwin->w_cursor, cap->count1);
curwin->w_p_fen = true; curwin->w_p_fen = true;
} }
break; break;
/* "zA": open fold at cursor recursively */ // "zA": open fold at cursor recursively
case 'A': if (hasFolding(curwin->w_cursor.lnum, NULL, NULL)) case 'A': if (hasFolding(curwin->w_cursor.lnum, NULL, NULL)) {
openFoldRecurse(curwin->w_cursor.lnum); openFoldRecurse(curwin->w_cursor);
else { } else {
closeFoldRecurse(curwin->w_cursor.lnum); closeFoldRecurse(curwin->w_cursor);
curwin->w_p_fen = true; curwin->w_p_fen = true;
} }
break; break;
/* "zo": open fold at cursor or Visual area */ // "zo": open fold at cursor or Visual area
case 'o': if (VIsual_active) case 'o': if (VIsual_active) {
nv_operator(cap); nv_operator(cap);
else } else {
openFold(curwin->w_cursor.lnum, cap->count1); openFold(curwin->w_cursor, cap->count1);
}
break; break;
/* "zO": open fold recursively */ // "zO": open fold recursively
case 'O': if (VIsual_active) case 'O': if (VIsual_active) {
nv_operator(cap); nv_operator(cap);
else } else {
openFoldRecurse(curwin->w_cursor.lnum); openFoldRecurse(curwin->w_cursor);
}
break; break;
/* "zc": close fold at cursor or Visual area */ // "zc": close fold at cursor or Visual area
case 'c': if (VIsual_active) case 'c': if (VIsual_active) {
nv_operator(cap); nv_operator(cap);
else } else {
closeFold(curwin->w_cursor.lnum, cap->count1); closeFold(curwin->w_cursor, cap->count1);
}
curwin->w_p_fen = true; curwin->w_p_fen = true;
break; break;
/* "zC": close fold recursively */ // "zC": close fold recursively
case 'C': if (VIsual_active) case 'C': if (VIsual_active) {
nv_operator(cap); nv_operator(cap);
else } else {
closeFoldRecurse(curwin->w_cursor.lnum); closeFoldRecurse(curwin->w_cursor);
}
curwin->w_p_fen = true; curwin->w_p_fen = true;
break; break;

View File

@ -119,7 +119,7 @@ static char opchars[][3] =
{ 'r', NUL, OPF_CHANGE }, // OP_REPLACE { 'r', NUL, OPF_CHANGE }, // OP_REPLACE
{ 'I', NUL, OPF_CHANGE }, // OP_INSERT { 'I', NUL, OPF_CHANGE }, // OP_INSERT
{ 'A', NUL, OPF_CHANGE }, // OP_APPEND { 'A', NUL, OPF_CHANGE }, // OP_APPEND
{ 'z', 'f', OPF_LINES }, // OP_FOLD { 'z', 'f', 0 }, // OP_FOLD
{ 'z', 'o', OPF_LINES }, // OP_FOLDOPEN { 'z', 'o', OPF_LINES }, // OP_FOLDOPEN
{ 'z', 'O', OPF_LINES }, // OP_FOLDOPENREC { 'z', 'O', OPF_LINES }, // OP_FOLDOPENREC
{ 'z', 'c', OPF_LINES }, // OP_FOLDCLOSE { 'z', 'c', OPF_LINES }, // OP_FOLDCLOSE