Merge pull request #12848 from jamessan/vim-8.2.1552

This commit is contained in:
James McCoy
2020-09-04 10:16:57 -04:00
committed by GitHub
3 changed files with 77 additions and 53 deletions

View File

@@ -346,7 +346,8 @@ submit_pr() {
fi
local git_remote
git_remote="$(find_git_remote)"
git_remote="$(find_git_remote)"
local pr_body
pr_body="$(git log --grep=vim-patch --reverse --format='#### %s%n%n%b%n' "${git_remote}"/master..HEAD)"
local patches
# Extract just the "vim-patch:X.Y.ZZZZ" or "vim-patch:sha" portion of each log

View File

@@ -573,31 +573,36 @@ void foldCreate(win_T *wp, linenr_T start, linenr_T end)
// Find the place to insert the new fold
gap = &wp->w_folds;
for (;; ) {
if (!foldFind(gap, start_rel, &fp))
break;
if (fp->fd_top + fp->fd_len > end_rel) {
/* New fold is completely inside this fold: Go one level deeper. */
gap = &fp->fd_nested;
start_rel -= fp->fd_top;
end_rel -= fp->fd_top;
if (use_level || fp->fd_flags == FD_LEVEL) {
use_level = true;
if (level >= wp->w_p_fdl) {
if (gap->ga_len == 0) {
i = 0;
} else {
for (;;) {
if (!foldFind(gap, start_rel, &fp)) {
break;
}
if (fp->fd_top + fp->fd_len > end_rel) {
// New fold is completely inside this fold: Go one level deeper.
gap = &fp->fd_nested;
start_rel -= fp->fd_top;
end_rel -= fp->fd_top;
if (use_level || fp->fd_flags == FD_LEVEL) {
use_level = true;
if (level >= wp->w_p_fdl) {
closed = true;
}
} else if (fp->fd_flags == FD_CLOSED) {
closed = true;
}
} else if (fp->fd_flags == FD_CLOSED) {
closed = true;
level++;
} else {
// This fold and new fold overlap: Insert here and move some folds
// inside the new fold.
break;
}
level++;
} else {
/* This fold and new fold overlap: Insert here and move some folds
* inside the new fold. */
break;
}
i = (int)(fp - (fold_T *)gap->ga_data);
}
i = (int)(fp - (fold_T *)gap->ga_data);
ga_grow(gap, 1);
{
fp = (fold_T *)gap->ga_data + i;
@@ -788,13 +793,15 @@ void foldUpdate(win_T *wp, linenr_T top, linenr_T bot)
return;
}
// Mark all folds from top to bot as maybe-small.
fold_T *fp;
(void)foldFind(&wp->w_folds, top, &fp);
while (fp < (fold_T *)wp->w_folds.ga_data + wp->w_folds.ga_len
&& fp->fd_top < bot) {
fp->fd_small = kNone;
fp++;
if (wp->w_folds.ga_len > 0) {
// Mark all folds from top to bot as maybe-small.
fold_T *fp;
(void)foldFind(&wp->w_folds, top, &fp);
while (fp < (fold_T *)wp->w_folds.ga_data + wp->w_folds.ga_len
&& fp->fd_top < bot) {
fp->fd_small = kNone;
fp++;
}
}
if (foldmethodIsIndent(wp)
@@ -1058,11 +1065,16 @@ void cloneFoldGrowArray(garray_T *from, garray_T *to)
* the first fold below it (careful: it can be beyond the end of the array!).
* Returns FALSE when there is no fold that contains "lnum".
*/
static int foldFind(const garray_T *gap, linenr_T lnum, fold_T **fpp)
static bool foldFind(const garray_T *gap, linenr_T lnum, fold_T **fpp)
{
linenr_T low, high;
fold_T *fp;
if (gap->ga_len == 0) {
*fpp = NULL;
return false;
}
/*
* Perform a binary search.
* "low" is lowest index of possible match.
@@ -1086,7 +1098,7 @@ static int foldFind(const garray_T *gap, linenr_T lnum, fold_T **fpp)
}
}
*fpp = fp + low;
return FALSE;
return false;
}
/* foldLevelWin() {{{2 */
@@ -1220,9 +1232,10 @@ setManualFoldWin(
gap = &wp->w_folds;
for (;; ) {
if (!foldFind(gap, lnum, &fp)) {
/* If there is a following fold, continue there next time. */
if (fp < (fold_T *)gap->ga_data + gap->ga_len)
// If there is a following fold, continue there next time.
if (fp != NULL && fp < (fold_T *)gap->ga_data + gap->ga_len) {
next = fp->fd_top + off;
}
break;
}
@@ -2269,14 +2282,15 @@ static linenr_T foldUpdateIEMSRecurse(
/* Find an existing fold to re-use. Preferably one that
* includes startlnum, otherwise one that ends just before
* startlnum or starts after it. */
if (foldFind(gap, startlnum, &fp)
|| (fp < ((fold_T *)gap->ga_data) + gap->ga_len
&& fp->fd_top <= firstlnum)
|| foldFind(gap, firstlnum - concat, &fp)
|| (fp < ((fold_T *)gap->ga_data) + gap->ga_len
&& ((lvl < level && fp->fd_top < flp->lnum)
|| (lvl >= level
&& fp->fd_top <= flp->lnum_save)))) {
if (gap->ga_len > 0
&& (foldFind(gap, startlnum, &fp)
|| (fp < ((fold_T *)gap->ga_data) + gap->ga_len
&& fp->fd_top <= firstlnum)
|| foldFind(gap, firstlnum - concat, &fp)
|| (fp < ((fold_T *)gap->ga_data) + gap->ga_len
&& ((lvl < level && fp->fd_top < flp->lnum)
|| (lvl >= level
&& fp->fd_top <= flp->lnum_save))))) {
if (fp->fd_top + fp->fd_len + concat > firstlnum) {
/* Use existing fold for the new fold. If it starts
* before where we started looking, extend it. If it
@@ -2367,7 +2381,11 @@ static linenr_T foldUpdateIEMSRecurse(
} else {
/* Insert new fold. Careful: ga_data may be NULL and it
* may change! */
i = (int)(fp - (fold_T *)gap->ga_data);
if (gap->ga_len == 0) {
i = 0;
} else {
i = (int)(fp - (fold_T *)gap->ga_data);
}
foldInsert(gap, i);
fp = (fold_T *)gap->ga_data + i;
/* The new fold continues until bot, unless we find the
@@ -2563,9 +2581,10 @@ static void foldInsert(garray_T *gap, int i)
ga_grow(gap, 1);
fp = (fold_T *)gap->ga_data + i;
if (i < gap->ga_len)
if (gap->ga_len > 0 && i < gap->ga_len) {
memmove(fp + 1, fp, sizeof(fold_T) * (size_t)(gap->ga_len - i));
++gap->ga_len;
}
gap->ga_len++;
ga_init(&fp->fd_nested, (int)sizeof(fold_T), 10);
}
@@ -2600,17 +2619,18 @@ static void foldSplit(buf_T *buf, garray_T *const gap,
* any between top and bot, they have been removed by the caller. */
garray_T *const gap1 = &fp->fd_nested;
garray_T *const gap2 = &fp[1].fd_nested;
(void)(foldFind(gap1, bot + 1 - fp->fd_top, &fp2));
const int len = (int)((fold_T *)gap1->ga_data + gap1->ga_len - fp2);
if (len > 0) {
ga_grow(gap2, len);
for (int idx = 0; idx < len; idx++) {
((fold_T *)gap2->ga_data)[idx] = fp2[idx];
((fold_T *)gap2->ga_data)[idx].fd_top
-= fp[1].fd_top - fp->fd_top;
if (foldFind(gap1, bot + 1 - fp->fd_top, &fp2)) {
const int len = (int)((fold_T *)gap1->ga_data + gap1->ga_len - fp2);
if (len > 0) {
ga_grow(gap2, len);
for (int idx = 0; idx < len; idx++) {
((fold_T *)gap2->ga_data)[idx] = fp2[idx];
((fold_T *)gap2->ga_data)[idx].fd_top
-= fp[1].fd_top - fp->fd_top;
}
gap2->ga_len = len;
gap1->ga_len -= len;
}
gap2->ga_len = len;
gap1->ga_len -= len;
}
fp->fd_len = top - fp->fd_top;
fold_changed = true;
@@ -2645,7 +2665,7 @@ static void foldRemove(
return; // nothing to do
}
for (;; ) {
while (gap->ga_len > 0) {
// Find fold that includes top or a following one.
if (foldFind(gap, top, &fp) && fp->fd_top < top) {
// 2: or 3: need to delete nested folds

View File

@@ -5663,6 +5663,9 @@ check_suggestions (
int len;
hlf_T attr;
if (gap->ga_len == 0) {
return;
}
stp = &SUG(*gap, 0);
for (int i = gap->ga_len - 1; i >= 0; --i) {
// Need to append what follows to check for "the the".