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 fi
local git_remote 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)" pr_body="$(git log --grep=vim-patch --reverse --format='#### %s%n%n%b%n' "${git_remote}"/master..HEAD)"
local patches local patches
# Extract just the "vim-patch:X.Y.ZZZZ" or "vim-patch:sha" portion of each log # 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 // Find the place to insert the new fold
gap = &wp->w_folds; gap = &wp->w_folds;
for (;; ) { if (gap->ga_len == 0) {
if (!foldFind(gap, start_rel, &fp)) i = 0;
break; } else {
if (fp->fd_top + fp->fd_len > end_rel) { for (;;) {
/* New fold is completely inside this fold: Go one level deeper. */ if (!foldFind(gap, start_rel, &fp)) {
gap = &fp->fd_nested; break;
start_rel -= fp->fd_top; }
end_rel -= fp->fd_top; if (fp->fd_top + fp->fd_len > end_rel) {
if (use_level || fp->fd_flags == FD_LEVEL) { // New fold is completely inside this fold: Go one level deeper.
use_level = true; gap = &fp->fd_nested;
if (level >= wp->w_p_fdl) { 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; closed = true;
} }
} else if (fp->fd_flags == FD_CLOSED) { level++;
closed = true; } 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); ga_grow(gap, 1);
{ {
fp = (fold_T *)gap->ga_data + i; fp = (fold_T *)gap->ga_data + i;
@@ -788,13 +793,15 @@ void foldUpdate(win_T *wp, linenr_T top, linenr_T bot)
return; return;
} }
// Mark all folds from top to bot as maybe-small. if (wp->w_folds.ga_len > 0) {
fold_T *fp; // Mark all folds from top to bot as maybe-small.
(void)foldFind(&wp->w_folds, top, &fp); fold_T *fp;
while (fp < (fold_T *)wp->w_folds.ga_data + wp->w_folds.ga_len (void)foldFind(&wp->w_folds, top, &fp);
&& fp->fd_top < bot) { while (fp < (fold_T *)wp->w_folds.ga_data + wp->w_folds.ga_len
fp->fd_small = kNone; && fp->fd_top < bot) {
fp++; fp->fd_small = kNone;
fp++;
}
} }
if (foldmethodIsIndent(wp) 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!). * 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". * 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; linenr_T low, high;
fold_T *fp; fold_T *fp;
if (gap->ga_len == 0) {
*fpp = NULL;
return false;
}
/* /*
* Perform a binary search. * Perform a binary search.
* "low" is lowest index of possible match. * "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; *fpp = fp + low;
return FALSE; return false;
} }
/* foldLevelWin() {{{2 */ /* foldLevelWin() {{{2 */
@@ -1220,9 +1232,10 @@ setManualFoldWin(
gap = &wp->w_folds; gap = &wp->w_folds;
for (;; ) { for (;; ) {
if (!foldFind(gap, lnum, &fp)) { if (!foldFind(gap, lnum, &fp)) {
/* If there is a following fold, continue there next time. */ // If there is a following fold, continue there next time.
if (fp < (fold_T *)gap->ga_data + gap->ga_len) if (fp != NULL && fp < (fold_T *)gap->ga_data + gap->ga_len) {
next = fp->fd_top + off; next = fp->fd_top + off;
}
break; break;
} }
@@ -2269,14 +2282,15 @@ static linenr_T foldUpdateIEMSRecurse(
/* Find an existing fold to re-use. Preferably one that /* Find an existing fold to re-use. Preferably one that
* includes startlnum, otherwise one that ends just before * includes startlnum, otherwise one that ends just before
* startlnum or starts after it. */ * startlnum or starts after it. */
if (foldFind(gap, startlnum, &fp) if (gap->ga_len > 0
|| (fp < ((fold_T *)gap->ga_data) + gap->ga_len && (foldFind(gap, startlnum, &fp)
&& fp->fd_top <= firstlnum) || (fp < ((fold_T *)gap->ga_data) + gap->ga_len
|| foldFind(gap, firstlnum - concat, &fp) && fp->fd_top <= firstlnum)
|| (fp < ((fold_T *)gap->ga_data) + gap->ga_len || foldFind(gap, firstlnum - concat, &fp)
&& ((lvl < level && fp->fd_top < flp->lnum) || (fp < ((fold_T *)gap->ga_data) + gap->ga_len
|| (lvl >= level && ((lvl < level && fp->fd_top < flp->lnum)
&& fp->fd_top <= flp->lnum_save)))) { || (lvl >= level
&& fp->fd_top <= flp->lnum_save))))) {
if (fp->fd_top + fp->fd_len + concat > firstlnum) { if (fp->fd_top + fp->fd_len + concat > firstlnum) {
/* Use existing fold for the new fold. If it starts /* Use existing fold for the new fold. If it starts
* before where we started looking, extend it. If it * before where we started looking, extend it. If it
@@ -2367,7 +2381,11 @@ static linenr_T foldUpdateIEMSRecurse(
} else { } else {
/* Insert new fold. Careful: ga_data may be NULL and it /* Insert new fold. Careful: ga_data may be NULL and it
* may change! */ * 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); foldInsert(gap, i);
fp = (fold_T *)gap->ga_data + i; fp = (fold_T *)gap->ga_data + i;
/* The new fold continues until bot, unless we find the /* 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); ga_grow(gap, 1);
fp = (fold_T *)gap->ga_data + i; 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)); 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); 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. */ * any between top and bot, they have been removed by the caller. */
garray_T *const gap1 = &fp->fd_nested; garray_T *const gap1 = &fp->fd_nested;
garray_T *const gap2 = &fp[1].fd_nested; garray_T *const gap2 = &fp[1].fd_nested;
(void)(foldFind(gap1, bot + 1 - fp->fd_top, &fp2)); if (foldFind(gap1, bot + 1 - fp->fd_top, &fp2)) {
const int len = (int)((fold_T *)gap1->ga_data + gap1->ga_len - fp2); const int len = (int)((fold_T *)gap1->ga_data + gap1->ga_len - fp2);
if (len > 0) { if (len > 0) {
ga_grow(gap2, len); ga_grow(gap2, len);
for (int idx = 0; idx < len; idx++) { for (int idx = 0; idx < len; idx++) {
((fold_T *)gap2->ga_data)[idx] = fp2[idx]; ((fold_T *)gap2->ga_data)[idx] = fp2[idx];
((fold_T *)gap2->ga_data)[idx].fd_top ((fold_T *)gap2->ga_data)[idx].fd_top
-= fp[1].fd_top - fp->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; fp->fd_len = top - fp->fd_top;
fold_changed = true; fold_changed = true;
@@ -2645,7 +2665,7 @@ static void foldRemove(
return; // nothing to do return; // nothing to do
} }
for (;; ) { while (gap->ga_len > 0) {
// Find fold that includes top or a following one. // Find fold that includes top or a following one.
if (foldFind(gap, top, &fp) && fp->fd_top < top) { if (foldFind(gap, top, &fp) && fp->fd_top < top) {
// 2: or 3: need to delete nested folds // 2: or 3: need to delete nested folds

View File

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