mirror of
https://github.com/neovim/neovim.git
synced 2025-09-29 14:38:32 +00:00
fold: fold_T.fd_small is TriState
This commit is contained in:
@@ -44,14 +44,14 @@
|
|||||||
* The info stored in both growarrays is the same: An array of fold_T.
|
* The info stored in both growarrays is the same: An array of fold_T.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
linenr_T fd_top; /* first line of fold; for nested fold
|
linenr_T fd_top; // first line of fold; for nested fold
|
||||||
* relative to parent */
|
// relative to parent
|
||||||
linenr_T fd_len; /* number of lines in the fold */
|
linenr_T fd_len; // number of lines in the fold
|
||||||
garray_T fd_nested; /* array of nested folds */
|
garray_T fd_nested; // array of nested folds
|
||||||
char fd_flags; /* see below */
|
char fd_flags; // see below
|
||||||
char fd_small; /* TRUE, FALSE or MAYBE: fold smaller than
|
TriState fd_small; // kTrue, kFalse, or kNone: fold smaller than
|
||||||
'foldminlines'; MAYBE applies to nested
|
// 'foldminlines'; kNone applies to nested
|
||||||
folds too */
|
// folds too
|
||||||
} fold_T;
|
} fold_T;
|
||||||
|
|
||||||
#define FD_OPEN 0 /* fold is open (nested ones can be closed) */
|
#define FD_OPEN 0 /* fold is open (nested ones can be closed) */
|
||||||
@@ -649,7 +649,7 @@ void foldCreate(linenr_T start, linenr_T end)
|
|||||||
if (!use_level)
|
if (!use_level)
|
||||||
curwin->w_fold_manual = true;
|
curwin->w_fold_manual = true;
|
||||||
fp->fd_flags = FD_CLOSED;
|
fp->fd_flags = FD_CLOSED;
|
||||||
fp->fd_small = MAYBE;
|
fp->fd_small = kNone;
|
||||||
|
|
||||||
/* redraw */
|
/* redraw */
|
||||||
changed_window_setting();
|
changed_window_setting();
|
||||||
@@ -787,8 +787,8 @@ void foldUpdate(win_T *wp, linenr_T top, linenr_T bot)
|
|||||||
(void)foldFind(&wp->w_folds, top, &fp);
|
(void)foldFind(&wp->w_folds, top, &fp);
|
||||||
while (fp < (fold_T *)wp->w_folds.ga_data + wp->w_folds.ga_len
|
while (fp < (fold_T *)wp->w_folds.ga_data + wp->w_folds.ga_len
|
||||||
&& fp->fd_top < bot) {
|
&& fp->fd_top < bot) {
|
||||||
fp->fd_small = MAYBE;
|
fp->fd_small = kNone;
|
||||||
++fp;
|
fp++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (foldmethodIsIndent(wp)
|
if (foldmethodIsIndent(wp)
|
||||||
@@ -1340,8 +1340,9 @@ static void deleteFoldEntry(garray_T *gap, int idx, int recursive)
|
|||||||
nfp[i].fd_top += fp->fd_top;
|
nfp[i].fd_top += fp->fd_top;
|
||||||
if (fp->fd_flags == FD_LEVEL)
|
if (fp->fd_flags == FD_LEVEL)
|
||||||
nfp[i].fd_flags = FD_LEVEL;
|
nfp[i].fd_flags = FD_LEVEL;
|
||||||
if (fp->fd_small == MAYBE)
|
if (fp->fd_small == kNone) {
|
||||||
nfp[i].fd_small = MAYBE;
|
nfp[i].fd_small = kNone;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* move the existing folds down to make room */
|
/* move the existing folds down to make room */
|
||||||
@@ -1526,15 +1527,18 @@ check_closed(
|
|||||||
} else if (fp->fd_flags == FD_CLOSED)
|
} else if (fp->fd_flags == FD_CLOSED)
|
||||||
closed = TRUE;
|
closed = TRUE;
|
||||||
|
|
||||||
/* Small fold isn't closed anyway. */
|
// Small fold isn't closed anyway.
|
||||||
if (fp->fd_small == MAYBE)
|
if (fp->fd_small == kNone) {
|
||||||
*maybe_smallp = TRUE;
|
*maybe_smallp = TRUE;
|
||||||
|
}
|
||||||
if (closed) {
|
if (closed) {
|
||||||
if (*maybe_smallp)
|
if (*maybe_smallp) {
|
||||||
fp->fd_small = MAYBE;
|
fp->fd_small = kNone;
|
||||||
|
}
|
||||||
checkSmall(win, fp, lnum_off);
|
checkSmall(win, fp, lnum_off);
|
||||||
if (fp->fd_small == TRUE)
|
if (fp->fd_small == kTrue) {
|
||||||
closed = FALSE;
|
closed = FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return closed;
|
return closed;
|
||||||
}
|
}
|
||||||
@@ -1553,35 +1557,33 @@ checkSmall(
|
|||||||
int count;
|
int count;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
if (fp->fd_small == MAYBE) {
|
if (fp->fd_small == kNone) {
|
||||||
/* Mark any nested folds to maybe-small */
|
// Mark any nested folds to maybe-small
|
||||||
setSmallMaybe(&fp->fd_nested);
|
setSmallMaybe(&fp->fd_nested);
|
||||||
|
|
||||||
if (fp->fd_len > curwin->w_p_fml)
|
if (fp->fd_len > curwin->w_p_fml) {
|
||||||
fp->fd_small = FALSE;
|
fp->fd_small = kFalse;
|
||||||
else {
|
} else {
|
||||||
count = 0;
|
count = 0;
|
||||||
for (n = 0; n < fp->fd_len; ++n) {
|
for (n = 0; n < fp->fd_len; n++) {
|
||||||
count += plines_win_nofold(wp, fp->fd_top + lnum_off + n);
|
count += plines_win_nofold(wp, fp->fd_top + lnum_off + n);
|
||||||
if (count > curwin->w_p_fml) {
|
if (count > curwin->w_p_fml) {
|
||||||
fp->fd_small = FALSE;
|
fp->fd_small = kFalse;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fp->fd_small = TRUE;
|
fp->fd_small = kTrue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* setSmallMaybe() {{{2 */
|
// setSmallMaybe() {{{2
|
||||||
/*
|
// Set small flags in "gap" to kNone.
|
||||||
* Set small flags in "gap" to MAYBE.
|
|
||||||
*/
|
|
||||||
static void setSmallMaybe(garray_T *gap)
|
static void setSmallMaybe(garray_T *gap)
|
||||||
{
|
{
|
||||||
fold_T *fp = (fold_T *)gap->ga_data;
|
fold_T *fp = (fold_T *)gap->ga_data;
|
||||||
for (int i = 0; i < gap->ga_len; ++i) {
|
for (int i = 0; i < gap->ga_len; i++) {
|
||||||
fp[i].fd_small = MAYBE;
|
fp[i].fd_small = kNone;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2361,13 +2363,14 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *gap, int level,
|
|||||||
flp->wp->w_fold_manual = true;
|
flp->wp->w_fold_manual = true;
|
||||||
} else
|
} else
|
||||||
fp->fd_flags = (fp - 1)->fd_flags;
|
fp->fd_flags = (fp - 1)->fd_flags;
|
||||||
fp->fd_small = MAYBE;
|
fp->fd_small = kNone;
|
||||||
/* If using the "marker", "expr" or "syntax" method, we
|
// If using the "marker", "expr" or "syntax" method, we
|
||||||
* need to continue until the end of the fold is found. */
|
// need to continue until the end of the fold is found.
|
||||||
if (getlevel == foldlevelMarker
|
if (getlevel == foldlevelMarker
|
||||||
|| getlevel == foldlevelExpr
|
|| getlevel == foldlevelExpr
|
||||||
|| getlevel == foldlevelSyntax)
|
|| getlevel == foldlevelSyntax) {
|
||||||
finish = TRUE;
|
finish = TRUE;
|
||||||
|
}
|
||||||
fold_changed = TRUE;
|
fold_changed = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -2454,7 +2457,7 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *gap, int level,
|
|||||||
/* Current fold at least extends until lnum. */
|
/* Current fold at least extends until lnum. */
|
||||||
if (fp->fd_len < flp->lnum - fp->fd_top) {
|
if (fp->fd_len < flp->lnum - fp->fd_top) {
|
||||||
fp->fd_len = flp->lnum - fp->fd_top;
|
fp->fd_len = flp->lnum - fp->fd_top;
|
||||||
fp->fd_small = MAYBE;
|
fp->fd_small = kNone;
|
||||||
fold_changed = TRUE;
|
fold_changed = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2566,8 +2569,8 @@ static void foldSplit(garray_T *gap, int i, linenr_T top, linenr_T bot)
|
|||||||
assert(fp[1].fd_top > bot);
|
assert(fp[1].fd_top > bot);
|
||||||
fp[1].fd_len = fp->fd_len - (fp[1].fd_top - fp->fd_top);
|
fp[1].fd_len = fp->fd_len - (fp[1].fd_top - fp->fd_top);
|
||||||
fp[1].fd_flags = fp->fd_flags;
|
fp[1].fd_flags = fp->fd_flags;
|
||||||
fp[1].fd_small = MAYBE;
|
fp[1].fd_small = kNone;
|
||||||
fp->fd_small = MAYBE;
|
fp->fd_small = kNone;
|
||||||
|
|
||||||
/* Move nested folds below bot to new fold. There can't be
|
/* Move nested folds below bot to new fold. There can't be
|
||||||
* any between top and bot, they have been removed by the caller. */
|
* any between top and bot, they have been removed by the caller. */
|
||||||
|
Reference in New Issue
Block a user