mirror of
https://github.com/neovim/neovim.git
synced 2025-09-30 06:58:35 +00:00
lint: fix linting issues
This commit is contained in:
@@ -651,7 +651,7 @@ void foldCreate(win_T *wp, linenr_T start, linenr_T end)
|
|||||||
fp->fd_flags = FD_CLOSED;
|
fp->fd_flags = FD_CLOSED;
|
||||||
fp->fd_small = kNone;
|
fp->fd_small = kNone;
|
||||||
|
|
||||||
/* redraw */
|
// redraw
|
||||||
changed_window_setting_win(wp);
|
changed_window_setting_win(wp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -730,13 +730,13 @@ void deleteFold(
|
|||||||
}
|
}
|
||||||
did_one = true;
|
did_one = true;
|
||||||
|
|
||||||
/* redraw window */
|
// redraw window
|
||||||
changed_window_setting_win(wp);
|
changed_window_setting_win(wp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!did_one) {
|
if (!did_one) {
|
||||||
EMSG(_(e_nofold));
|
EMSG(_(e_nofold));
|
||||||
/* Force a redraw to remove the Visual highlighting. */
|
// Force a redraw to remove the Visual highlighting.
|
||||||
if (had_visual) {
|
if (had_visual) {
|
||||||
redraw_buf_later(wp->w_buffer, INVERTED);
|
redraw_buf_later(wp->w_buffer, INVERTED);
|
||||||
}
|
}
|
||||||
@@ -1373,13 +1373,17 @@ void foldMarkAdjust(win_T *wp, linenr_T line1, linenr_T line2, long amount, long
|
|||||||
line2 = line1 - amount_after - 1;
|
line2 = line1 - amount_after - 1;
|
||||||
/* If appending a line in Insert mode, it should be included in the fold
|
/* If appending a line in Insert mode, it should be included in the fold
|
||||||
* just above the line. */
|
* just above the line. */
|
||||||
if ((State & INSERT) && amount == (linenr_T)1 && line2 == MAXLNUM)
|
if ((State & INSERT) && amount == (linenr_T)1 && line2 == MAXLNUM) {
|
||||||
--line1;
|
line1--;
|
||||||
|
}
|
||||||
foldMarkAdjustRecurse(wp, &wp->w_folds, line1, line2, amount, amount_after);
|
foldMarkAdjustRecurse(wp, &wp->w_folds, line1, line2, amount, amount_after);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* foldMarkAdjustRecurse() {{{2 */
|
// foldMarkAdjustRecurse() {{{2
|
||||||
static void foldMarkAdjustRecurse(win_T *wp, garray_T *gap, linenr_T line1, linenr_T line2, long amount, long amount_after)
|
static void foldMarkAdjustRecurse(
|
||||||
|
win_T *wp, garray_T *gap,
|
||||||
|
linenr_T line1, linenr_T line2, long amount, long amount_after
|
||||||
|
)
|
||||||
{
|
{
|
||||||
fold_T *fp;
|
fold_T *fp;
|
||||||
linenr_T last;
|
linenr_T last;
|
||||||
@@ -1435,7 +1439,7 @@ static void foldMarkAdjustRecurse(win_T *wp, garray_T *gap, linenr_T line1, line
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (fp->fd_top < top) {
|
if (fp->fd_top < top) {
|
||||||
/* 2 or 3: need to correct nested folds too */
|
// 2 or 3: need to correct nested folds too
|
||||||
foldMarkAdjustRecurse(wp, &fp->fd_nested, line1 - fp->fd_top,
|
foldMarkAdjustRecurse(wp, &fp->fd_nested, line1 - fp->fd_top,
|
||||||
line2 - fp->fd_top, amount, amount_after);
|
line2 - fp->fd_top, amount, amount_after);
|
||||||
if (last <= line2) {
|
if (last <= line2) {
|
||||||
@@ -1667,14 +1671,15 @@ deleteFoldMarkers(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (recursive) {
|
if (recursive) {
|
||||||
for (int i = 0; i < fp->fd_nested.ga_len; ++i) {
|
for (int i = 0; i < fp->fd_nested.ga_len; i++) {
|
||||||
deleteFoldMarkers(wp, (fold_T *)fp->fd_nested.ga_data + i, TRUE,
|
deleteFoldMarkers(wp, (fold_T *)fp->fd_nested.ga_data + i, true,
|
||||||
lnum_off + fp->fd_top);
|
lnum_off + fp->fd_top);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foldDelMarker(wp->w_buffer, fp->fd_top + lnum_off, wp->w_p_fmr, foldstartmarkerlen);
|
foldDelMarker(wp->w_buffer, fp->fd_top+lnum_off, wp->w_p_fmr,
|
||||||
foldDelMarker(wp->w_buffer, fp->fd_top + lnum_off + fp->fd_len - 1, foldendmarker,
|
foldstartmarkerlen);
|
||||||
foldendmarkerlen);
|
foldDelMarker(wp->w_buffer, fp->fd_top + lnum_off + fp->fd_len - 1,
|
||||||
|
foldendmarker, foldendmarkerlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
// foldDelMarker() {{{2
|
// foldDelMarker() {{{2
|
||||||
@@ -1683,7 +1688,9 @@ deleteFoldMarkers(
|
|||||||
// Delete 'commentstring' if it matches.
|
// Delete 'commentstring' if it matches.
|
||||||
// If the marker is not found, there is no error message. Could be a missing
|
// If the marker is not found, there is no error message. Could be a missing
|
||||||
// close-marker.
|
// close-marker.
|
||||||
static void foldDelMarker(buf_T *buf, linenr_T lnum, char_u *marker, size_t markerlen)
|
static void foldDelMarker(
|
||||||
|
buf_T *buf, linenr_T lnum, char_u *marker, size_t markerlen
|
||||||
|
)
|
||||||
{
|
{
|
||||||
char_u *newline;
|
char_u *newline;
|
||||||
char_u *cms = buf->b_p_cms;
|
char_u *cms = buf->b_p_cms;
|
||||||
@@ -1694,7 +1701,7 @@ static void foldDelMarker(buf_T *buf, linenr_T lnum, char_u *marker, size_t mark
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
char_u *line = ml_get_buf(buf, lnum, false);
|
char_u *line = ml_get_buf(buf, lnum, false);
|
||||||
for (char_u *p = line; *p != NUL; ++p) {
|
for (char_u *p = line; *p != NUL; p++) {
|
||||||
if (STRNCMP(p, marker, markerlen) != 0) {
|
if (STRNCMP(p, marker, markerlen) != 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -2096,7 +2103,7 @@ static void foldUpdateIEMS(win_T *const wp, linenr_T top, linenr_T bot)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* There can't be any folds from start until end now. */
|
// There can't be any folds from start until end now.
|
||||||
foldRemove(wp, &wp->w_folds, start, end);
|
foldRemove(wp, &wp->w_folds, start, end);
|
||||||
|
|
||||||
/* If some fold changed, need to redraw and position cursor. */
|
/* If some fold changed, need to redraw and position cursor. */
|
||||||
@@ -2342,7 +2349,8 @@ static linenr_T foldUpdateIEMSRecurse(
|
|||||||
// A fold that starts at or after startlnum and stops
|
// A fold that starts at or after startlnum and stops
|
||||||
// before the new fold must be deleted. Continue
|
// before the new fold must be deleted. Continue
|
||||||
// looking for the next one.
|
// looking for the next one.
|
||||||
deleteFoldEntry(flp->wp, gap, (int)(fp - (fold_T *)gap->ga_data), true);
|
deleteFoldEntry(flp->wp, gap,
|
||||||
|
(int)(fp - (fold_T *)gap->ga_data), true);
|
||||||
} else {
|
} else {
|
||||||
/* A fold has some lines above startlnum, truncate it
|
/* A fold has some lines above startlnum, truncate it
|
||||||
* to stop just above startlnum. */
|
* to stop just above startlnum. */
|
||||||
@@ -2513,7 +2521,7 @@ static linenr_T foldUpdateIEMSRecurse(
|
|||||||
break;
|
break;
|
||||||
if (fp2->fd_top + fp2->fd_len > flp->lnum) {
|
if (fp2->fd_top + fp2->fd_len > flp->lnum) {
|
||||||
if (fp2->fd_top < flp->lnum) {
|
if (fp2->fd_top < flp->lnum) {
|
||||||
/* Make fold that includes lnum start at lnum. */
|
// Make fold that includes lnum start at lnum.
|
||||||
foldMarkAdjustRecurse(flp->wp, &fp2->fd_nested,
|
foldMarkAdjustRecurse(flp->wp, &fp2->fd_nested,
|
||||||
(linenr_T)0, (long)(flp->lnum - fp2->fd_top - 1),
|
(linenr_T)0, (long)(flp->lnum - fp2->fd_top - 1),
|
||||||
(linenr_T)MAXLNUM, (long)(fp2->fd_top-flp->lnum));
|
(linenr_T)MAXLNUM, (long)(fp2->fd_top-flp->lnum));
|
||||||
@@ -2523,7 +2531,7 @@ static linenr_T foldUpdateIEMSRecurse(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (lvl >= level) {
|
if (lvl >= level) {
|
||||||
/* merge new fold with existing fold that follows */
|
// merge new fold with existing fold that follows
|
||||||
foldMerge(flp->wp, fp, gap, fp2);
|
foldMerge(flp->wp, fp, gap, fp2);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -2623,7 +2631,9 @@ static void foldSplit(buf_T *buf, garray_T *const gap,
|
|||||||
* 5: made to start below "bot".
|
* 5: made to start below "bot".
|
||||||
* 6: not changed
|
* 6: not changed
|
||||||
*/
|
*/
|
||||||
static void foldRemove(win_T *const wp, garray_T *gap, linenr_T top, linenr_T bot)
|
static void foldRemove(
|
||||||
|
win_T *const wp, garray_T *gap, linenr_T top, linenr_T bot
|
||||||
|
)
|
||||||
{
|
{
|
||||||
fold_T *fp = NULL;
|
fold_T *fp = NULL;
|
||||||
|
|
||||||
@@ -2638,7 +2648,8 @@ static void foldRemove(win_T *const wp, garray_T *gap, linenr_T top, linenr_T bo
|
|||||||
foldRemove(wp, &fp->fd_nested, top - fp->fd_top, bot - fp->fd_top);
|
foldRemove(wp, &fp->fd_nested, top - fp->fd_top, bot - fp->fd_top);
|
||||||
if (fp->fd_top + fp->fd_len - 1 > bot) {
|
if (fp->fd_top + fp->fd_len - 1 > bot) {
|
||||||
// 3: need to split it.
|
// 3: need to split it.
|
||||||
foldSplit(wp->w_buffer, gap, (int)(fp - (fold_T *)gap->ga_data), top, bot);
|
foldSplit(wp->w_buffer, gap,
|
||||||
|
(int)(fp - (fold_T *)gap->ga_data), top, bot);
|
||||||
} else {
|
} else {
|
||||||
// 2: truncate fold at "top".
|
// 2: truncate fold at "top".
|
||||||
fp->fd_len = top - fp->fd_top;
|
fp->fd_len = top - fp->fd_top;
|
||||||
@@ -2656,7 +2667,8 @@ static void foldRemove(win_T *const wp, garray_T *gap, linenr_T top, linenr_T bo
|
|||||||
fold_changed = true;
|
fold_changed = true;
|
||||||
if (fp->fd_top + fp->fd_len - 1 > bot) {
|
if (fp->fd_top + fp->fd_len - 1 > bot) {
|
||||||
// 5: Make fold that includes bot start below bot.
|
// 5: Make fold that includes bot start below bot.
|
||||||
foldMarkAdjustRecurse(wp, &fp->fd_nested,
|
foldMarkAdjustRecurse(
|
||||||
|
wp, &fp->fd_nested,
|
||||||
(linenr_T)0, (long)(bot - fp->fd_top),
|
(linenr_T)0, (long)(bot - fp->fd_top),
|
||||||
(linenr_T)MAXLNUM, (long)(fp->fd_top - bot - 1));
|
(linenr_T)MAXLNUM, (long)(fp->fd_top - bot - 1));
|
||||||
fp->fd_len -= bot - fp->fd_top + 1;
|
fp->fd_len -= bot - fp->fd_top + 1;
|
||||||
@@ -2728,8 +2740,11 @@ static void truncate_fold(win_T *const wp, fold_T *fp, linenr_T end)
|
|||||||
#define FOLD_END(fp) ((fp)->fd_top + (fp)->fd_len - 1)
|
#define FOLD_END(fp) ((fp)->fd_top + (fp)->fd_len - 1)
|
||||||
#define VALID_FOLD(fp, gap) ((fp) < ((fold_T *)(gap)->ga_data + (gap)->ga_len))
|
#define VALID_FOLD(fp, gap) ((fp) < ((fold_T *)(gap)->ga_data + (gap)->ga_len))
|
||||||
#define FOLD_INDEX(fp, gap) ((size_t)(fp - ((fold_T *)(gap)->ga_data)))
|
#define FOLD_INDEX(fp, gap) ((size_t)(fp - ((fold_T *)(gap)->ga_data)))
|
||||||
void foldMoveRange(win_T *const wp, garray_T *gap, const linenr_T line1, const linenr_T line2,
|
void foldMoveRange(
|
||||||
const linenr_T dest)
|
win_T *const wp, garray_T *gap,
|
||||||
|
const linenr_T line1, const linenr_T line2,
|
||||||
|
const linenr_T dest
|
||||||
|
)
|
||||||
{
|
{
|
||||||
fold_T *fp;
|
fold_T *fp;
|
||||||
const linenr_T range_len = line2 - line1 + 1;
|
const linenr_T range_len = line2 - line1 + 1;
|
||||||
@@ -2847,8 +2862,9 @@ static void foldMerge(win_T *const wp, fold_T *fp1, garray_T *gap, fold_T *fp2)
|
|||||||
|
|
||||||
/* If the last nested fold in fp1 touches the first nested fold in fp2,
|
/* If the last nested fold in fp1 touches the first nested fold in fp2,
|
||||||
* merge them recursively. */
|
* merge them recursively. */
|
||||||
if (foldFind(gap1, fp1->fd_len - 1L, &fp3) && foldFind(gap2, 0L, &fp4))
|
if (foldFind(gap1, fp1->fd_len - 1L, &fp3) && foldFind(gap2, 0L, &fp4)) {
|
||||||
foldMerge(wp, fp3, gap2, fp4);
|
foldMerge(wp, fp3, gap2, fp4);
|
||||||
|
}
|
||||||
|
|
||||||
/* Move nested folds in fp2 to the end of fp1. */
|
/* Move nested folds in fp2 to the end of fp1. */
|
||||||
if (!GA_EMPTY(gap2)) {
|
if (!GA_EMPTY(gap2)) {
|
||||||
|
@@ -2432,9 +2432,10 @@ int ml_replace_buf(buf_T *buf, linenr_T lnum, char_u *line, bool copy)
|
|||||||
if (line == NULL) /* just checking... */
|
if (line == NULL) /* just checking... */
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
/* When starting up, we might still need to create the memfile */
|
// When starting up, we might still need to create the memfile
|
||||||
if (buf->b_ml.ml_mfp == NULL && open_buffer(FALSE, NULL, 0) == FAIL)
|
if (buf->b_ml.ml_mfp == NULL && open_buffer(false, NULL, 0) == FAIL) {
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
bool readlen = true;
|
bool readlen = true;
|
||||||
|
|
||||||
@@ -4000,7 +4001,7 @@ long ml_find_line_or_offset(buf_T *buf, linenr_T lnum, long *offp, bool no_ff)
|
|||||||
int ffdos = !no_ff && (get_fileformat(buf) == EOL_DOS);
|
int ffdos = !no_ff && (get_fileformat(buf) == EOL_DOS);
|
||||||
int extra = 0;
|
int extra = 0;
|
||||||
|
|
||||||
/* take care of cached line first */
|
// take care of cached line first
|
||||||
ml_flush_line(buf);
|
ml_flush_line(buf);
|
||||||
|
|
||||||
if (buf->b_ml.ml_usedchunks == -1
|
if (buf->b_ml.ml_usedchunks == -1
|
||||||
|
Reference in New Issue
Block a user