mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge #8749 from janlazo/clint-tristate
This commit is contained in:
commit
e861da247e
@ -3299,6 +3299,13 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension,
|
||||
error(filename, linenum, 'readability/bool', 4,
|
||||
'Use %s instead of %s.' % (token.lower(), token))
|
||||
|
||||
# Detect MAYBE
|
||||
match = Search(r'\b(MAYBE)\b', line)
|
||||
if match:
|
||||
token = match.group(1)
|
||||
error(filename, linenum, 'readability/bool', 4,
|
||||
'Use kNONE from TriState instead of %s.' % token)
|
||||
|
||||
# Detect preincrement/predecrement
|
||||
match = Match(r'^\s*(?:\+\+|--)', line)
|
||||
if match:
|
||||
|
@ -48,9 +48,9 @@ static int diff_flags = DIFF_FILLER;
|
||||
|
||||
#define LBUFLEN 50 // length of line in diff file
|
||||
|
||||
// TRUE when "diff -a" works, FALSE when it doesn't work, MAYBE when not
|
||||
// checked yet
|
||||
static int diff_a_works = MAYBE;
|
||||
// kTrue when "diff -a" works, kFalse when it doesn't work,
|
||||
// kNone when not checked yet
|
||||
static TriState diff_a_works = kNone;
|
||||
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
@ -686,9 +686,9 @@ void ex_diffupdate(exarg_T *eap)
|
||||
// there are differences.
|
||||
// May try twice, first with "-a" and then without.
|
||||
int io_error = false;
|
||||
bool ok = false;
|
||||
TriState ok = kFalse;
|
||||
for (;;) {
|
||||
ok = false;
|
||||
ok = kFalse;
|
||||
FILE *fd = mch_fopen(tmp_orig, "w");
|
||||
|
||||
if (fd == NULL) {
|
||||
@ -722,7 +722,7 @@ void ex_diffupdate(exarg_T *eap)
|
||||
}
|
||||
|
||||
if (STRNCMP(linebuf, "1c1", 3) == 0) {
|
||||
ok = TRUE;
|
||||
ok = kTrue;
|
||||
}
|
||||
}
|
||||
fclose(fd);
|
||||
@ -739,7 +739,7 @@ void ex_diffupdate(exarg_T *eap)
|
||||
}
|
||||
|
||||
// If we checked if "-a" works already, break here.
|
||||
if (diff_a_works != MAYBE) {
|
||||
if (diff_a_works != kNone) {
|
||||
break;
|
||||
}
|
||||
diff_a_works = ok;
|
||||
@ -755,7 +755,7 @@ void ex_diffupdate(exarg_T *eap)
|
||||
EMSG(_("E810: Cannot read or write temp files"));
|
||||
}
|
||||
EMSG(_("E97: Cannot create diffs"));
|
||||
diff_a_works = MAYBE;
|
||||
diff_a_works = kNone;
|
||||
goto theend;
|
||||
}
|
||||
|
||||
@ -830,7 +830,7 @@ static void diff_file(const char *const tmp_orig, const char *const tmp_new,
|
||||
* differences are of no use. Ignore errors, diff returns
|
||||
* non-zero when differences have been found. */
|
||||
vim_snprintf(cmd, len, "diff %s%s%s%s%s %s",
|
||||
diff_a_works ? "-a " : "",
|
||||
diff_a_works == kFalse ? "" : "-a ",
|
||||
"",
|
||||
(diff_flags & DIFF_IWHITE) ? "-b " : "",
|
||||
(diff_flags & DIFF_ICASE) ? "-i " : "",
|
||||
@ -1486,7 +1486,7 @@ int diff_check(win_T *wp, linenr_T lnum)
|
||||
}
|
||||
|
||||
// A closed fold never has filler lines.
|
||||
if (hasFoldingWin(wp, lnum, NULL, NULL, TRUE, NULL)) {
|
||||
if (hasFoldingWin(wp, lnum, NULL, NULL, true, NULL)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1793,7 +1793,7 @@ void diff_set_topline(win_T *fromwin, win_T *towin)
|
||||
|
||||
check_topfill(towin, false);
|
||||
(void)hasFoldingWin(towin, towin->w_topline, &towin->w_topline,
|
||||
NULL, TRUE, NULL);
|
||||
NULL, true, NULL);
|
||||
}
|
||||
|
||||
/// This is called when 'diffopt' is changed.
|
||||
|
@ -242,7 +242,7 @@ static int ins_need_undo; /* call u_save() before inserting a
|
||||
|
||||
static int did_add_space = FALSE; /* auto_format() added an extra space
|
||||
under the cursor */
|
||||
static int dont_sync_undo = false; // CTRL-G U prevents syncing undo
|
||||
static TriState dont_sync_undo = kFalse; // CTRL-G U prevents syncing undo
|
||||
// for the next left/right cursor
|
||||
|
||||
static linenr_T o_lnum = 0;
|
||||
@ -595,10 +595,10 @@ static int insert_check(VimState *state)
|
||||
s->lastc = s->c; // remember previous char for CTRL-D
|
||||
|
||||
// After using CTRL-G U the next cursor key will not break undo.
|
||||
if (dont_sync_undo == MAYBE) {
|
||||
dont_sync_undo = true;
|
||||
if (dont_sync_undo == kNone) {
|
||||
dont_sync_undo = kTrue;
|
||||
} else {
|
||||
dont_sync_undo = false;
|
||||
dont_sync_undo = kFalse;
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -997,7 +997,7 @@ static int insert_handle_key(InsertState *s)
|
||||
if (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL)) {
|
||||
ins_s_left();
|
||||
} else {
|
||||
ins_left(dont_sync_undo == false);
|
||||
ins_left(dont_sync_undo == kFalse);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1010,7 +1010,7 @@ static int insert_handle_key(InsertState *s)
|
||||
if (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL)) {
|
||||
ins_s_right();
|
||||
} else {
|
||||
ins_right(dont_sync_undo == false);
|
||||
ins_right(dont_sync_undo == kFalse);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -7174,7 +7174,7 @@ static void ins_ctrl_g(void)
|
||||
case 'U':
|
||||
// Allow one left/right cursor movement with the next char,
|
||||
// without breaking undo.
|
||||
dont_sync_undo = MAYBE;
|
||||
dont_sync_undo = kNone;
|
||||
break;
|
||||
|
||||
/* Unknown CTRL-G command, reserved for future expansion. */
|
||||
@ -7954,7 +7954,7 @@ static void ins_left(bool end_change)
|
||||
} else {
|
||||
vim_beep(BO_CRSR);
|
||||
}
|
||||
dont_sync_undo = false;
|
||||
dont_sync_undo = kFalse;
|
||||
}
|
||||
|
||||
static void ins_home(int c)
|
||||
@ -8039,7 +8039,7 @@ static void ins_right(bool end_change)
|
||||
} else {
|
||||
vim_beep(BO_CRSR);
|
||||
}
|
||||
dont_sync_undo = false;
|
||||
dont_sync_undo = kFalse;
|
||||
}
|
||||
|
||||
static void ins_s_right(void)
|
||||
|
@ -4913,11 +4913,7 @@ void fix_help_buffer(void)
|
||||
{
|
||||
linenr_T lnum;
|
||||
char_u *line;
|
||||
int in_example = FALSE;
|
||||
int len;
|
||||
char_u *fname;
|
||||
char_u *p;
|
||||
char_u *rt;
|
||||
bool in_example = false;
|
||||
|
||||
// Set filetype to "help".
|
||||
if (STRCMP(curbuf->b_p_ft, "help") != 0) {
|
||||
@ -4927,9 +4923,9 @@ void fix_help_buffer(void)
|
||||
}
|
||||
|
||||
if (!syntax_present(curwin)) {
|
||||
for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; ++lnum) {
|
||||
line = ml_get_buf(curbuf, lnum, FALSE);
|
||||
len = (int)STRLEN(line);
|
||||
for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; lnum++) {
|
||||
line = ml_get_buf(curbuf, lnum, false);
|
||||
const size_t len = STRLEN(line);
|
||||
if (in_example && len > 0 && !ascii_iswhite(line[0])) {
|
||||
/* End of example: non-white or '<' in first column. */
|
||||
if (line[0] == '<') {
|
||||
@ -4937,14 +4933,14 @@ void fix_help_buffer(void)
|
||||
line = ml_get_buf(curbuf, lnum, TRUE);
|
||||
line[0] = ' ';
|
||||
}
|
||||
in_example = FALSE;
|
||||
in_example = false;
|
||||
}
|
||||
if (!in_example && len > 0) {
|
||||
if (line[len - 1] == '>' && (len == 1 || line[len - 2] == ' ')) {
|
||||
/* blank-out a '>' in the last column (start of example) */
|
||||
line = ml_get_buf(curbuf, lnum, TRUE);
|
||||
line[len - 1] = ' ';
|
||||
in_example = TRUE;
|
||||
in_example = true;
|
||||
} else if (line[len - 1] == '~') {
|
||||
/* blank-out a '~' at the end of line (header marker) */
|
||||
line = ml_get_buf(curbuf, lnum, TRUE);
|
||||
@ -4958,7 +4954,7 @@ void fix_help_buffer(void)
|
||||
* In the "help.txt" and "help.abx" file, add the locally added help
|
||||
* files. This uses the very first line in the help file.
|
||||
*/
|
||||
fname = path_tail(curbuf->b_fname);
|
||||
char_u *const fname = path_tail(curbuf->b_fname);
|
||||
if (fnamecmp(fname, "help.txt") == 0
|
||||
|| (fnamencmp(fname, "help.", 5) == 0
|
||||
&& ASCII_ISALPHA(fname[5])
|
||||
@ -4973,17 +4969,15 @@ void fix_help_buffer(void)
|
||||
|
||||
/* Go through all directories in 'runtimepath', skipping
|
||||
* $VIMRUNTIME. */
|
||||
p = p_rtp;
|
||||
char_u *p = p_rtp;
|
||||
while (*p != NUL) {
|
||||
copy_option_part(&p, NameBuff, MAXPATHL, ",");
|
||||
rt = (char_u *)vim_getenv("VIMRUNTIME");
|
||||
char_u *const rt = (char_u *)vim_getenv("VIMRUNTIME");
|
||||
if (rt != NULL
|
||||
&& path_full_compare(rt, NameBuff, false) != kEqualFiles) {
|
||||
int fcount;
|
||||
char_u **fnames;
|
||||
FILE *fd;
|
||||
char_u *s;
|
||||
int fi;
|
||||
vimconv_T vc;
|
||||
char_u *cp;
|
||||
|
||||
@ -5001,29 +4995,24 @@ void fix_help_buffer(void)
|
||||
if (gen_expand_wildcards(1, buff_list, &fcount,
|
||||
&fnames, EW_FILE|EW_SILENT) == OK
|
||||
&& fcount > 0) {
|
||||
int i1;
|
||||
int i2;
|
||||
char_u *f1;
|
||||
char_u *f2;
|
||||
char_u *t1;
|
||||
char_u *e1;
|
||||
char_u *e2;
|
||||
|
||||
/* If foo.abx is found use it instead of foo.txt in
|
||||
* the same directory. */
|
||||
for (i1 = 0; i1 < fcount; ++i1) {
|
||||
for (i2 = 0; i2 < fcount; ++i2) {
|
||||
if (i1 == i2)
|
||||
// If foo.abx is found use it instead of foo.txt in
|
||||
// the same directory.
|
||||
for (int i1 = 0; i1 < fcount; i1++) {
|
||||
for (int i2 = 0; i2 < fcount; i2++) {
|
||||
if (i1 == i2) {
|
||||
continue;
|
||||
if (fnames[i1] == NULL || fnames[i2] == NULL)
|
||||
}
|
||||
if (fnames[i1] == NULL || fnames[i2] == NULL) {
|
||||
continue;
|
||||
f1 = fnames[i1];
|
||||
f2 = fnames[i2];
|
||||
t1 = path_tail(f1);
|
||||
if (fnamencmp(f1, f2, t1 - f1) != 0)
|
||||
}
|
||||
const char_u *const f1 = fnames[i1];
|
||||
const char_u *const f2 = fnames[i2];
|
||||
const char_u *const t1 = path_tail(f1);
|
||||
if (fnamencmp(f1, f2, t1 - f1) != 0) {
|
||||
continue;
|
||||
e1 = vim_strrchr(t1, '.');
|
||||
e2 = vim_strrchr(path_tail(f2), '.');
|
||||
}
|
||||
const char_u *const e1 = vim_strrchr(t1, '.');
|
||||
const char_u *const e2 = vim_strrchr(path_tail(f2), '.');
|
||||
if (e1 == NULL || e2 == NULL) {
|
||||
continue;
|
||||
}
|
||||
@ -5044,10 +5033,12 @@ void fix_help_buffer(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
for (fi = 0; fi < fcount; ++fi) {
|
||||
if (fnames[fi] == NULL)
|
||||
for (int fi = 0; fi < fcount; fi++) {
|
||||
if (fnames[fi] == NULL) {
|
||||
continue;
|
||||
fd = mch_fopen((char *)fnames[fi], "r");
|
||||
}
|
||||
|
||||
FILE *const fd = mch_fopen((char *)fnames[fi], "r");
|
||||
if (fd == NULL) {
|
||||
continue;
|
||||
}
|
||||
@ -5055,9 +5046,9 @@ void fix_help_buffer(void)
|
||||
if (IObuff[0] == '*'
|
||||
&& (s = vim_strchr(IObuff + 1, '*'))
|
||||
!= NULL) {
|
||||
int this_utf = MAYBE;
|
||||
/* Change tag definition to a
|
||||
* reference and remove <CR>/<NL>. */
|
||||
TriState this_utf = kNone;
|
||||
// Change tag definition to a
|
||||
// reference and remove <CR>/<NL>.
|
||||
IObuff[0] = '|';
|
||||
*s = '|';
|
||||
while (*s != NUL) {
|
||||
@ -5067,13 +5058,12 @@ void fix_help_buffer(void)
|
||||
* above 127 is found and no
|
||||
* illegal byte sequence is found.
|
||||
*/
|
||||
if (*s >= 0x80 && this_utf != FALSE) {
|
||||
int l;
|
||||
|
||||
this_utf = TRUE;
|
||||
l = utf_ptr2len(s);
|
||||
if (l == 1)
|
||||
this_utf = FALSE;
|
||||
if (*s >= 0x80 && this_utf != kFalse) {
|
||||
this_utf = kTrue;
|
||||
const int l = utf_ptr2len(s);
|
||||
if (l == 1) {
|
||||
this_utf = kFalse;
|
||||
}
|
||||
s += l - 1;
|
||||
}
|
||||
++s;
|
||||
@ -5082,19 +5072,21 @@ void fix_help_buffer(void)
|
||||
* conversion to the current
|
||||
* 'encoding' may be required. */
|
||||
vc.vc_type = CONV_NONE;
|
||||
convert_setup(&vc, (char_u *)(
|
||||
this_utf == TRUE ? "utf-8"
|
||||
: "latin1"), p_enc);
|
||||
if (vc.vc_type == CONV_NONE)
|
||||
/* No conversion needed. */
|
||||
convert_setup(
|
||||
&vc,
|
||||
(char_u *)(this_utf == kTrue ? "utf-8" : "latin1"),
|
||||
p_enc);
|
||||
if (vc.vc_type == CONV_NONE) {
|
||||
// No conversion needed.
|
||||
cp = IObuff;
|
||||
else {
|
||||
/* Do the conversion. If it fails
|
||||
* use the unconverted text. */
|
||||
} else {
|
||||
// Do the conversion. If it fails
|
||||
// use the unconverted text.
|
||||
cp = string_convert(&vc, IObuff, NULL);
|
||||
if (cp == NULL)
|
||||
if (cp == NULL) {
|
||||
cp = IObuff;
|
||||
}
|
||||
}
|
||||
convert_setup(&vc, NULL, NULL);
|
||||
|
||||
ml_append(lnum, cp, (colnr_T)0, FALSE);
|
||||
@ -5138,22 +5130,16 @@ void ex_viusage(exarg_T *eap)
|
||||
/// @param tagname Name of the tags file ("tags" for English, "tags-fr" for
|
||||
/// French)
|
||||
/// @param add_help_tags Whether to add the "help-tags" tag
|
||||
static void helptags_one(char_u *dir, char_u *ext, char_u *tagfname,
|
||||
bool add_help_tags)
|
||||
static void helptags_one(char_u *const dir, const char_u *const ext,
|
||||
const char_u *const tagfname, const bool add_help_tags)
|
||||
{
|
||||
FILE *fd_tags;
|
||||
FILE *fd;
|
||||
garray_T ga;
|
||||
int filecount;
|
||||
char_u **files;
|
||||
char_u *p1, *p2;
|
||||
int fi;
|
||||
char_u *s;
|
||||
char_u *fname;
|
||||
int utf8 = MAYBE;
|
||||
int this_utf8;
|
||||
int firstline;
|
||||
int mix = FALSE; /* detected mixed encodings */
|
||||
TriState utf8 = kNone;
|
||||
bool mix = false; // detected mixed encodings
|
||||
|
||||
// Find all *.txt files.
|
||||
size_t dirlen = STRLCPY(NameBuff, dir, sizeof(NameBuff));
|
||||
@ -5186,7 +5172,8 @@ static void helptags_one(char_u *dir, char_u *ext, char_u *tagfname,
|
||||
EMSG(_(e_fnametoolong));
|
||||
return;
|
||||
}
|
||||
fd_tags = mch_fopen((char *)NameBuff, "w");
|
||||
|
||||
FILE *const fd_tags = mch_fopen((char *)NameBuff, "w");
|
||||
if (fd_tags == NULL) {
|
||||
EMSG2(_("E152: Cannot open %s for writing"), NameBuff);
|
||||
FreeWild(filecount, files);
|
||||
@ -5209,44 +5196,44 @@ static void helptags_one(char_u *dir, char_u *ext, char_u *tagfname,
|
||||
/*
|
||||
* Go over all the files and extract the tags.
|
||||
*/
|
||||
for (fi = 0; fi < filecount && !got_int; ++fi) {
|
||||
fd = mch_fopen((char *)files[fi], "r");
|
||||
for (int fi = 0; fi < filecount && !got_int; fi++) {
|
||||
FILE *const fd = mch_fopen((char *)files[fi], "r");
|
||||
if (fd == NULL) {
|
||||
EMSG2(_("E153: Unable to open %s for reading"), files[fi]);
|
||||
continue;
|
||||
}
|
||||
fname = files[fi] + dirlen + 1;
|
||||
const char_u *const fname = files[fi] + dirlen + 1;
|
||||
|
||||
firstline = TRUE;
|
||||
bool firstline = true;
|
||||
while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int) {
|
||||
if (firstline) {
|
||||
/* Detect utf-8 file by a non-ASCII char in the first line. */
|
||||
this_utf8 = MAYBE;
|
||||
for (s = IObuff; *s != NUL; ++s)
|
||||
// Detect utf-8 file by a non-ASCII char in the first line.
|
||||
TriState this_utf8 = kNone;
|
||||
for (s = IObuff; *s != NUL; s++) {
|
||||
if (*s >= 0x80) {
|
||||
int l;
|
||||
|
||||
this_utf8 = TRUE;
|
||||
l = utf_ptr2len(s);
|
||||
this_utf8 = kTrue;
|
||||
const int l = utf_ptr2len(s);
|
||||
if (l == 1) {
|
||||
/* Illegal UTF-8 byte sequence. */
|
||||
this_utf8 = FALSE;
|
||||
// Illegal UTF-8 byte sequence.
|
||||
this_utf8 = kFalse;
|
||||
break;
|
||||
}
|
||||
s += l - 1;
|
||||
}
|
||||
if (this_utf8 == MAYBE) /* only ASCII characters found */
|
||||
this_utf8 = FALSE;
|
||||
if (utf8 == MAYBE) /* first file */
|
||||
}
|
||||
if (this_utf8 == kNone) { // only ASCII characters found
|
||||
this_utf8 = kFalse;
|
||||
}
|
||||
if (utf8 == kNone) { // first file
|
||||
utf8 = this_utf8;
|
||||
else if (utf8 != this_utf8) {
|
||||
} else if (utf8 != this_utf8) {
|
||||
EMSG2(_(
|
||||
"E670: Mix of help file encodings within a language: %s"),
|
||||
files[fi]);
|
||||
mix = !got_int;
|
||||
got_int = TRUE;
|
||||
}
|
||||
firstline = FALSE;
|
||||
firstline = false;
|
||||
}
|
||||
p1 = vim_strchr(IObuff, '*'); /* find first '*' */
|
||||
while (p1 != NULL) {
|
||||
@ -5316,8 +5303,9 @@ static void helptags_one(char_u *dir, char_u *ext, char_u *tagfname,
|
||||
}
|
||||
}
|
||||
|
||||
if (utf8 == TRUE)
|
||||
if (utf8 == kTrue) {
|
||||
fprintf(fd_tags, "!_TAG_FILE_ENCODING\tutf-8\t//\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the tags into the file.
|
||||
|
@ -7395,7 +7395,7 @@ static void ex_operators(exarg_T *eap)
|
||||
oa.end.lnum = eap->line2;
|
||||
oa.line_count = eap->line2 - eap->line1 + 1;
|
||||
oa.motion_type = kMTLineWise;
|
||||
virtual_op = false;
|
||||
virtual_op = kFalse;
|
||||
if (eap->cmdidx != CMD_yank) { // position cursor for undo
|
||||
setpcmark();
|
||||
curwin->w_cursor.lnum = eap->line1;
|
||||
@ -7426,7 +7426,7 @@ static void ex_operators(exarg_T *eap)
|
||||
op_shift(&oa, FALSE, eap->amount);
|
||||
break;
|
||||
}
|
||||
virtual_op = MAYBE;
|
||||
virtual_op = kNone;
|
||||
ex_may_print(eap);
|
||||
}
|
||||
|
||||
|
425
src/nvim/fold.c
425
src/nvim/fold.c
@ -44,14 +44,14 @@
|
||||
* The info stored in both growarrays is the same: An array of fold_T.
|
||||
*/
|
||||
typedef struct {
|
||||
linenr_T fd_top; /* first line of fold; for nested fold
|
||||
* relative to parent */
|
||||
linenr_T fd_len; /* number of lines in the fold */
|
||||
garray_T fd_nested; /* array of nested folds */
|
||||
char fd_flags; /* see below */
|
||||
char fd_small; /* TRUE, FALSE or MAYBE: fold smaller than
|
||||
'foldminlines'; MAYBE applies to nested
|
||||
folds too */
|
||||
linenr_T fd_top; // first line of fold; for nested fold
|
||||
// relative to parent
|
||||
linenr_T fd_len; // number of lines in the fold
|
||||
garray_T fd_nested; // array of nested folds
|
||||
char fd_flags; // see below
|
||||
TriState fd_small; // kTrue, kFalse, or kNone: fold smaller than
|
||||
// 'foldminlines'; kNone applies to nested
|
||||
// folds too
|
||||
} fold_T;
|
||||
|
||||
#define FD_OPEN 0 /* fold is open (nested ones can be closed) */
|
||||
@ -76,8 +76,8 @@ typedef struct {
|
||||
this line (copy of "end" of prev. line) */
|
||||
} fline_T;
|
||||
|
||||
/* Flag is set when redrawing is needed. */
|
||||
static int fold_changed;
|
||||
// Flag is set when redrawing is needed.
|
||||
static bool fold_changed;
|
||||
|
||||
/* Function used by foldUpdateIEMSRecurse */
|
||||
typedef void (*LevelGetter)(fline_T *);
|
||||
@ -147,29 +147,27 @@ int hasAnyFolding(win_T *win)
|
||||
*/
|
||||
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 */
|
||||
bool hasFoldingWin(
|
||||
win_T *win,
|
||||
linenr_T lnum,
|
||||
linenr_T *firstp,
|
||||
linenr_T *lastp,
|
||||
int cache, /* when TRUE: use cached values of window */
|
||||
foldinfo_T *infop /* where to store fold info */
|
||||
win_T *const win,
|
||||
const linenr_T lnum,
|
||||
linenr_T *const firstp,
|
||||
linenr_T *const lastp,
|
||||
const bool cache, // when true: use cached values of window
|
||||
foldinfo_T *const infop // where to store fold info
|
||||
)
|
||||
{
|
||||
int had_folded = FALSE;
|
||||
bool had_folded = false;
|
||||
linenr_T first = 0;
|
||||
linenr_T last = 0;
|
||||
linenr_T lnum_rel = lnum;
|
||||
int x;
|
||||
fold_T *fp;
|
||||
int level = 0;
|
||||
int use_level = FALSE;
|
||||
int maybe_small = FALSE;
|
||||
garray_T *gap;
|
||||
bool use_level = false;
|
||||
bool maybe_small = false;
|
||||
int low_level = 0;
|
||||
|
||||
checkupdate(win);
|
||||
@ -187,7 +185,7 @@ bool hasFoldingWin(
|
||||
* First look in cached info for displayed lines. This is probably
|
||||
* the fastest, but it can only be used if the entry is still valid.
|
||||
*/
|
||||
x = find_wl_entry(win, lnum);
|
||||
const int x = find_wl_entry(win, lnum);
|
||||
if (x >= 0) {
|
||||
first = win->w_lines[x].wl_lnum;
|
||||
last = win->w_lines[x].wl_lastlnum;
|
||||
@ -199,7 +197,7 @@ bool hasFoldingWin(
|
||||
/*
|
||||
* Recursively search for a fold that contains "lnum".
|
||||
*/
|
||||
gap = &win->w_folds;
|
||||
garray_T *gap = &win->w_folds;
|
||||
for (;; ) {
|
||||
if (!foldFind(gap, lnum_rel, &fp))
|
||||
break;
|
||||
@ -274,14 +272,11 @@ int foldLevel(linenr_T lnum)
|
||||
return foldLevelWin(curwin, lnum);
|
||||
}
|
||||
|
||||
/* lineFolded() {{{2 */
|
||||
/*
|
||||
* Low level function to check if a line is folded. Doesn't use any caching.
|
||||
* Return TRUE if line is folded.
|
||||
* Return FALSE if line is not folded.
|
||||
* Return MAYBE if the line is folded when next to a folded line.
|
||||
*/
|
||||
int lineFolded(win_T *win, linenr_T lnum)
|
||||
// lineFolded() {{{2
|
||||
// Low level function to check if a line is folded. Doesn't use any caching.
|
||||
// Return true if line is folded.
|
||||
// Return false if line is not folded.
|
||||
bool lineFolded(win_T *const win, const linenr_T lnum)
|
||||
{
|
||||
return foldedCount(win, lnum, NULL) != 0;
|
||||
}
|
||||
@ -299,8 +294,9 @@ long foldedCount(win_T *win, linenr_T lnum, foldinfo_T *infop)
|
||||
{
|
||||
linenr_T last;
|
||||
|
||||
if (hasFoldingWin(win, lnum, NULL, &last, FALSE, infop))
|
||||
if (hasFoldingWin(win, lnum, NULL, &last, false, infop)) {
|
||||
return (long)(last - lnum + 1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -649,7 +645,7 @@ void foldCreate(linenr_T start, linenr_T end)
|
||||
if (!use_level)
|
||||
curwin->w_fold_manual = true;
|
||||
fp->fd_flags = FD_CLOSED;
|
||||
fp->fd_small = MAYBE;
|
||||
fp->fd_small = kNone;
|
||||
|
||||
/* redraw */
|
||||
changed_window_setting();
|
||||
@ -663,36 +659,31 @@ void foldCreate(linenr_T start, linenr_T end)
|
||||
* When "end" is not 0, delete all folds from "start" to "end".
|
||||
* When "recursive" is TRUE delete recursively.
|
||||
*/
|
||||
void
|
||||
deleteFold(
|
||||
linenr_T start,
|
||||
linenr_T end,
|
||||
int recursive,
|
||||
int had_visual // TRUE when Visual selection used
|
||||
void deleteFold(
|
||||
const linenr_T start,
|
||||
const linenr_T end,
|
||||
const int recursive,
|
||||
const bool had_visual // true when Visual selection used
|
||||
)
|
||||
{
|
||||
garray_T *gap;
|
||||
fold_T *fp;
|
||||
garray_T *found_ga;
|
||||
fold_T *found_fp = NULL;
|
||||
linenr_T found_off = 0;
|
||||
int use_level;
|
||||
int maybe_small = FALSE;
|
||||
bool maybe_small = false;
|
||||
int level = 0;
|
||||
linenr_T lnum = start;
|
||||
linenr_T lnum_off;
|
||||
int did_one = FALSE;
|
||||
bool did_one = false;
|
||||
linenr_T first_lnum = MAXLNUM;
|
||||
linenr_T last_lnum = 0;
|
||||
|
||||
checkupdate(curwin);
|
||||
|
||||
while (lnum <= end) {
|
||||
/* Find the deepest fold for "start". */
|
||||
gap = &curwin->w_folds;
|
||||
found_ga = NULL;
|
||||
lnum_off = 0;
|
||||
use_level = FALSE;
|
||||
// Find the deepest fold for "start".
|
||||
garray_T *gap = &curwin->w_folds;
|
||||
garray_T *found_ga = NULL;
|
||||
linenr_T lnum_off = 0;
|
||||
bool use_level = false;
|
||||
for (;; ) {
|
||||
if (!foldFind(gap, lnum - lnum_off, &fp))
|
||||
break;
|
||||
@ -728,7 +719,7 @@ deleteFold(
|
||||
parseMarker(curwin);
|
||||
deleteFoldMarkers(found_fp, recursive, found_off);
|
||||
}
|
||||
did_one = TRUE;
|
||||
did_one = true;
|
||||
|
||||
/* redraw window */
|
||||
changed_window_setting();
|
||||
@ -787,8 +778,8 @@ void foldUpdate(win_T *wp, linenr_T top, linenr_T bot)
|
||||
(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 = MAYBE;
|
||||
++fp;
|
||||
fp->fd_small = kNone;
|
||||
fp++;
|
||||
}
|
||||
|
||||
if (foldmethodIsIndent(wp)
|
||||
@ -831,44 +822,34 @@ void foldUpdateAll(win_T *win)
|
||||
redraw_win_later(win, NOT_VALID);
|
||||
}
|
||||
|
||||
/* foldMoveTo() {{{2 */
|
||||
/*
|
||||
* If "updown" is FALSE: Move to the start or end of the fold.
|
||||
* If "updown" is TRUE: move to fold at the same level.
|
||||
* If not moved return FAIL.
|
||||
*/
|
||||
int
|
||||
foldMoveTo(
|
||||
int updown,
|
||||
int dir, // FORWARD or BACKWARD
|
||||
long count
|
||||
// foldMoveTo() {{{2
|
||||
//
|
||||
// If "updown" is false: Move to the start or end of the fold.
|
||||
// If "updown" is true: move to fold at the same level.
|
||||
// If not moved return FAIL.
|
||||
int foldMoveTo(
|
||||
const bool updown,
|
||||
const int dir, // FORWARD or BACKWARD
|
||||
const long count
|
||||
)
|
||||
{
|
||||
long n;
|
||||
int retval = FAIL;
|
||||
linenr_T lnum_off;
|
||||
linenr_T lnum_found;
|
||||
linenr_T lnum;
|
||||
int use_level;
|
||||
int maybe_small;
|
||||
garray_T *gap;
|
||||
fold_T *fp;
|
||||
int level;
|
||||
int last;
|
||||
|
||||
checkupdate(curwin);
|
||||
|
||||
/* Repeat "count" times. */
|
||||
for (n = 0; n < count; ++n) {
|
||||
/* Find nested folds. Stop when a fold is closed. The deepest fold
|
||||
* that moves the cursor is used. */
|
||||
lnum_off = 0;
|
||||
gap = &curwin->w_folds;
|
||||
use_level = FALSE;
|
||||
maybe_small = FALSE;
|
||||
lnum_found = curwin->w_cursor.lnum;
|
||||
level = 0;
|
||||
last = FALSE;
|
||||
// Repeat "count" times.
|
||||
for (long n = 0; n < count; n++) {
|
||||
// Find nested folds. Stop when a fold is closed. The deepest fold
|
||||
// that moves the cursor is used.
|
||||
linenr_T lnum_off = 0;
|
||||
garray_T *gap = &curwin->w_folds;
|
||||
bool use_level = false;
|
||||
bool maybe_small = false;
|
||||
linenr_T lnum_found = curwin->w_cursor.lnum;
|
||||
int level = 0;
|
||||
bool last = false;
|
||||
for (;; ) {
|
||||
if (!foldFind(gap, curwin->w_cursor.lnum - lnum_off, &fp)) {
|
||||
if (!updown)
|
||||
@ -886,14 +867,15 @@ foldMoveTo(
|
||||
}
|
||||
/* don't look for contained folds, they will always move
|
||||
* the cursor too far. */
|
||||
last = TRUE;
|
||||
last = true;
|
||||
}
|
||||
|
||||
if (!last) {
|
||||
/* Check if this fold is closed. */
|
||||
if (check_closed(curwin, fp, &use_level, level,
|
||||
&maybe_small, lnum_off))
|
||||
last = TRUE;
|
||||
&maybe_small, lnum_off)) {
|
||||
last = true;
|
||||
}
|
||||
|
||||
/* "[z" and "]z" stop at closed fold */
|
||||
if (last && !updown)
|
||||
@ -1306,25 +1288,21 @@ static void foldOpenNested(fold_T *fpr)
|
||||
}
|
||||
}
|
||||
|
||||
/* deleteFoldEntry() {{{2 */
|
||||
/*
|
||||
* Delete fold "idx" from growarray "gap".
|
||||
* When "recursive" is TRUE also delete all the folds contained in it.
|
||||
* When "recursive" is FALSE contained folds are moved one level up.
|
||||
*/
|
||||
static void deleteFoldEntry(garray_T *gap, int idx, int recursive)
|
||||
// deleteFoldEntry() {{{2
|
||||
// Delete fold "idx" from growarray "gap".
|
||||
// When "recursive" is true also delete all the folds contained in it.
|
||||
// When "recursive" is false contained folds are moved one level up.
|
||||
static void deleteFoldEntry(garray_T *const gap, const int idx,
|
||||
const bool recursive)
|
||||
{
|
||||
fold_T *fp;
|
||||
int i;
|
||||
fold_T *nfp;
|
||||
|
||||
fp = (fold_T *)gap->ga_data + idx;
|
||||
fold_T *fp = (fold_T *)gap->ga_data + idx;
|
||||
if (recursive || GA_EMPTY(&fp->fd_nested)) {
|
||||
/* recursively delete the contained folds */
|
||||
// recursively delete the contained folds
|
||||
deleteFoldRecurse(&fp->fd_nested);
|
||||
--gap->ga_len;
|
||||
if (idx < gap->ga_len)
|
||||
memmove(fp, fp + 1, sizeof(fold_T) * (size_t)(gap->ga_len - idx));
|
||||
gap->ga_len--;
|
||||
if (idx < gap->ga_len) {
|
||||
memmove(fp, fp + 1, sizeof(*fp) * (size_t)(gap->ga_len - idx));
|
||||
}
|
||||
} else {
|
||||
/* Move nested folds one level up, to overwrite the fold that is
|
||||
* deleted. */
|
||||
@ -1334,22 +1312,24 @@ static void deleteFoldEntry(garray_T *gap, int idx, int recursive)
|
||||
/* Get "fp" again, the array may have been reallocated. */
|
||||
fp = (fold_T *)gap->ga_data + idx;
|
||||
|
||||
/* adjust fd_top and fd_flags for the moved folds */
|
||||
nfp = (fold_T *)fp->fd_nested.ga_data;
|
||||
for (i = 0; i < moved; ++i) {
|
||||
// adjust fd_top and fd_flags for the moved folds
|
||||
fold_T *nfp = (fold_T *)fp->fd_nested.ga_data;
|
||||
for (int i = 0; i < moved; i++) {
|
||||
nfp[i].fd_top += fp->fd_top;
|
||||
if (fp->fd_flags == FD_LEVEL)
|
||||
nfp[i].fd_flags = FD_LEVEL;
|
||||
if (fp->fd_small == MAYBE)
|
||||
nfp[i].fd_small = MAYBE;
|
||||
if (fp->fd_small == kNone) {
|
||||
nfp[i].fd_small = kNone;
|
||||
}
|
||||
}
|
||||
|
||||
/* move the existing folds down to make room */
|
||||
if (idx + 1 < gap->ga_len)
|
||||
// move the existing folds down to make room
|
||||
if (idx + 1 < gap->ga_len) {
|
||||
memmove(fp + moved, fp + 1,
|
||||
sizeof(fold_T) * (size_t)(gap->ga_len - (idx + 1)));
|
||||
/* move the contained folds one level up */
|
||||
memmove(fp, nfp, sizeof(fold_T) * (size_t)moved);
|
||||
sizeof(*fp) * (size_t)(gap->ga_len - (idx + 1)));
|
||||
}
|
||||
// move the contained folds one level up
|
||||
memmove(fp, nfp, sizeof(*fp) * (size_t)moved);
|
||||
xfree(nfp);
|
||||
gap->ga_len += moved - 1;
|
||||
}
|
||||
@ -1429,14 +1409,15 @@ static void foldMarkAdjustRecurse(garray_T *gap, linenr_T line1, linenr_T line2,
|
||||
fp->fd_top += amount_after;
|
||||
} else {
|
||||
if (fp->fd_top >= top && last <= line2) {
|
||||
/* 4. fold completely contained in range */
|
||||
// 4. fold completely contained in range
|
||||
if (amount == MAXLNUM) {
|
||||
/* Deleting lines: delete the fold completely */
|
||||
deleteFoldEntry(gap, i, TRUE);
|
||||
--i; /* adjust index for deletion */
|
||||
--fp;
|
||||
} else
|
||||
// Deleting lines: delete the fold completely
|
||||
deleteFoldEntry(gap, i, true);
|
||||
i--; // adjust index for deletion
|
||||
fp--;
|
||||
} else {
|
||||
fp->fd_top += amount;
|
||||
}
|
||||
} else {
|
||||
if (fp->fd_top < top) {
|
||||
/* 2 or 3: need to correct nested folds too */
|
||||
@ -1505,36 +1486,40 @@ static int getDeepestNestingRecurse(garray_T *gap)
|
||||
/*
|
||||
* Check if a fold is closed and update the info needed to check nested folds.
|
||||
*/
|
||||
static int
|
||||
check_closed(
|
||||
win_T *win,
|
||||
fold_T *fp,
|
||||
int *use_levelp, // TRUE: outer fold had FD_LEVEL
|
||||
int level, // folding depth
|
||||
int *maybe_smallp, // TRUE: outer this had fd_small == MAYBE
|
||||
linenr_T lnum_off // line number offset for fp->fd_top
|
||||
static bool check_closed(
|
||||
win_T *const win,
|
||||
fold_T *const fp,
|
||||
bool *const use_levelp, // true: outer fold had FD_LEVEL
|
||||
const int level, // folding depth
|
||||
bool *const maybe_smallp, // true: outer this had fd_small == kNone
|
||||
const linenr_T lnum_off // line number offset for fp->fd_top
|
||||
)
|
||||
{
|
||||
int closed = FALSE;
|
||||
bool closed = false;
|
||||
|
||||
/* Check if this fold is closed. If the flag is FD_LEVEL this
|
||||
* fold and all folds it contains depend on 'foldlevel'. */
|
||||
if (*use_levelp || fp->fd_flags == FD_LEVEL) {
|
||||
*use_levelp = TRUE;
|
||||
if (level >= win->w_p_fdl)
|
||||
closed = TRUE;
|
||||
} else if (fp->fd_flags == FD_CLOSED)
|
||||
closed = TRUE;
|
||||
*use_levelp = true;
|
||||
if (level >= win->w_p_fdl) {
|
||||
closed = true;
|
||||
}
|
||||
} else if (fp->fd_flags == FD_CLOSED) {
|
||||
closed = true;
|
||||
}
|
||||
|
||||
/* Small fold isn't closed anyway. */
|
||||
if (fp->fd_small == MAYBE)
|
||||
*maybe_smallp = TRUE;
|
||||
// Small fold isn't closed anyway.
|
||||
if (fp->fd_small == kNone) {
|
||||
*maybe_smallp = true;
|
||||
}
|
||||
if (closed) {
|
||||
if (*maybe_smallp)
|
||||
fp->fd_small = MAYBE;
|
||||
if (*maybe_smallp) {
|
||||
fp->fd_small = kNone;
|
||||
}
|
||||
checkSmall(win, fp, lnum_off);
|
||||
if (fp->fd_small == TRUE)
|
||||
closed = FALSE;
|
||||
if (fp->fd_small == kTrue) {
|
||||
closed = false;
|
||||
}
|
||||
}
|
||||
return closed;
|
||||
}
|
||||
@ -1545,43 +1530,38 @@ check_closed(
|
||||
*/
|
||||
static void
|
||||
checkSmall(
|
||||
win_T *wp,
|
||||
fold_T *fp,
|
||||
linenr_T lnum_off // offset for fp->fd_top
|
||||
win_T *const wp,
|
||||
fold_T *const fp,
|
||||
const linenr_T lnum_off // offset for fp->fd_top
|
||||
)
|
||||
{
|
||||
int count;
|
||||
int n;
|
||||
|
||||
if (fp->fd_small == MAYBE) {
|
||||
/* Mark any nested folds to maybe-small */
|
||||
if (fp->fd_small == kNone) {
|
||||
// Mark any nested folds to maybe-small
|
||||
setSmallMaybe(&fp->fd_nested);
|
||||
|
||||
if (fp->fd_len > curwin->w_p_fml)
|
||||
fp->fd_small = FALSE;
|
||||
else {
|
||||
count = 0;
|
||||
for (n = 0; n < fp->fd_len; ++n) {
|
||||
if (fp->fd_len > curwin->w_p_fml) {
|
||||
fp->fd_small = kFalse;
|
||||
} else {
|
||||
int count = 0;
|
||||
for (int n = 0; n < fp->fd_len; n++) {
|
||||
count += plines_win_nofold(wp, fp->fd_top + lnum_off + n);
|
||||
if (count > curwin->w_p_fml) {
|
||||
fp->fd_small = FALSE;
|
||||
fp->fd_small = kFalse;
|
||||
return;
|
||||
}
|
||||
}
|
||||
fp->fd_small = TRUE;
|
||||
fp->fd_small = kTrue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* setSmallMaybe() {{{2 */
|
||||
/*
|
||||
* Set small flags in "gap" to MAYBE.
|
||||
*/
|
||||
// setSmallMaybe() {{{2
|
||||
// Set small flags in "gap" to kNone.
|
||||
static void setSmallMaybe(garray_T *gap)
|
||||
{
|
||||
fold_T *fp = (fold_T *)gap->ga_data;
|
||||
for (int i = 0; i < gap->ga_len; ++i) {
|
||||
fp[i].fd_small = MAYBE;
|
||||
for (int i = 0; i < gap->ga_len; i++) {
|
||||
fp[i].fd_small = kNone;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1896,13 +1876,10 @@ void foldtext_cleanup(char_u *str)
|
||||
* Update the folding for window "wp", at least from lines "top" to "bot".
|
||||
* Return TRUE if any folds did change.
|
||||
*/
|
||||
static void foldUpdateIEMS(win_T *wp, linenr_T top, linenr_T bot)
|
||||
static void foldUpdateIEMS(win_T *const wp, linenr_T top, linenr_T bot)
|
||||
{
|
||||
linenr_T start;
|
||||
linenr_T end;
|
||||
fline_T fline;
|
||||
void (*getlevel)(fline_T *);
|
||||
int level;
|
||||
fold_T *fp;
|
||||
|
||||
/* Avoid problems when being called recursively. */
|
||||
@ -1928,12 +1905,13 @@ static void foldUpdateIEMS(win_T *wp, linenr_T top, linenr_T bot)
|
||||
bot += diff_context;
|
||||
}
|
||||
|
||||
/* When deleting lines at the end of the buffer "top" can be past the end
|
||||
* of the buffer. */
|
||||
if (top > wp->w_buffer->b_ml.ml_line_count)
|
||||
// When deleting lines at the end of the buffer "top" can be past the end
|
||||
// of the buffer.
|
||||
if (top > wp->w_buffer->b_ml.ml_line_count) {
|
||||
top = wp->w_buffer->b_ml.ml_line_count;
|
||||
}
|
||||
|
||||
fold_changed = FALSE;
|
||||
fold_changed = false;
|
||||
fline.wp = wp;
|
||||
fline.off = 0;
|
||||
fline.lvl = 0;
|
||||
@ -1954,8 +1932,8 @@ static void foldUpdateIEMS(win_T *wp, linenr_T top, linenr_T bot)
|
||||
/* Need to get the level of the line above top, it is used if there is
|
||||
* no marker at the top. */
|
||||
if (top > 1) {
|
||||
/* Get the fold level at top - 1. */
|
||||
level = foldLevelWin(wp, top - 1);
|
||||
// Get the fold level at top - 1.
|
||||
const int level = foldLevelWin(wp, top - 1);
|
||||
|
||||
/* The fold may end just above the top, check for that. */
|
||||
fline.lnum = top - 1;
|
||||
@ -2031,11 +2009,12 @@ static void foldUpdateIEMS(win_T *wp, linenr_T top, linenr_T bot)
|
||||
}
|
||||
}
|
||||
|
||||
start = fline.lnum;
|
||||
end = bot;
|
||||
/* Do at least one line. */
|
||||
if (start > end && end < wp->w_buffer->b_ml.ml_line_count)
|
||||
linenr_T start = fline.lnum;
|
||||
linenr_T end = bot;
|
||||
// Do at least one line.
|
||||
if (start > end && end < wp->w_buffer->b_ml.ml_line_count) {
|
||||
end = start;
|
||||
}
|
||||
while (!got_int) {
|
||||
/* Always stop at the end of the file ("end" can be past the end of
|
||||
* the file). */
|
||||
@ -2126,22 +2105,21 @@ static void foldUpdateIEMS(win_T *wp, linenr_T top, linenr_T bot)
|
||||
* Returns bot, which may have been increased for lines that also need to be
|
||||
* updated as a result of a detected change in the fold.
|
||||
*/
|
||||
static linenr_T foldUpdateIEMSRecurse(garray_T *gap, int level,
|
||||
linenr_T startlnum, fline_T *flp,
|
||||
LevelGetter getlevel,
|
||||
linenr_T bot,
|
||||
char topflags /* containing fold flags */
|
||||
)
|
||||
static linenr_T foldUpdateIEMSRecurse(
|
||||
garray_T *const gap, const int level, const linenr_T startlnum,
|
||||
fline_T *const flp, LevelGetter getlevel, linenr_T bot,
|
||||
const char topflags // containing fold flags
|
||||
)
|
||||
{
|
||||
linenr_T ll;
|
||||
fold_T *fp = NULL;
|
||||
fold_T *fp2;
|
||||
int lvl = level;
|
||||
linenr_T startlnum2 = startlnum;
|
||||
linenr_T firstlnum = flp->lnum; /* first lnum we got */
|
||||
const linenr_T firstlnum = flp->lnum; // first lnum we got
|
||||
int i;
|
||||
int finish = FALSE;
|
||||
linenr_T linecount = flp->wp->w_buffer->b_ml.ml_line_count - flp->off;
|
||||
bool finish = false;
|
||||
const linenr_T linecount = flp->wp->w_buffer->b_ml.ml_line_count - flp->off;
|
||||
int concat;
|
||||
|
||||
/*
|
||||
@ -2309,8 +2287,9 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *gap, int level,
|
||||
* found. */
|
||||
if (getlevel == foldlevelMarker
|
||||
|| getlevel == foldlevelExpr
|
||||
|| getlevel == foldlevelSyntax)
|
||||
finish = TRUE;
|
||||
|| getlevel == foldlevelSyntax) {
|
||||
finish = true;
|
||||
}
|
||||
}
|
||||
if (fp->fd_top == startlnum && concat) {
|
||||
i = (int)(fp - (fold_T *)gap->ga_data);
|
||||
@ -2325,11 +2304,10 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *gap, int level,
|
||||
break;
|
||||
}
|
||||
if (fp->fd_top >= startlnum) {
|
||||
/* A fold that starts at or after startlnum and stops
|
||||
* before the new fold must be deleted. Continue
|
||||
* looking for the next one. */
|
||||
deleteFoldEntry(gap,
|
||||
(int)(fp - (fold_T *)gap->ga_data), TRUE);
|
||||
// A fold that starts at or after startlnum and stops
|
||||
// before the new fold must be deleted. Continue
|
||||
// looking for the next one.
|
||||
deleteFoldEntry(gap, (int)(fp - (fold_T *)gap->ga_data), true);
|
||||
} else {
|
||||
/* A fold has some lines above startlnum, truncate it
|
||||
* to stop just above startlnum. */
|
||||
@ -2337,7 +2315,7 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *gap, int level,
|
||||
foldMarkAdjustRecurse(&fp->fd_nested,
|
||||
(linenr_T)fp->fd_len, (linenr_T)MAXLNUM,
|
||||
(linenr_T)MAXLNUM, 0L);
|
||||
fold_changed = TRUE;
|
||||
fold_changed = true;
|
||||
}
|
||||
} else {
|
||||
/* Insert new fold. Careful: ga_data may be NULL and it
|
||||
@ -2361,14 +2339,15 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *gap, int level,
|
||||
flp->wp->w_fold_manual = true;
|
||||
} else
|
||||
fp->fd_flags = (fp - 1)->fd_flags;
|
||||
fp->fd_small = MAYBE;
|
||||
/* If using the "marker", "expr" or "syntax" method, we
|
||||
* need to continue until the end of the fold is found. */
|
||||
fp->fd_small = kNone;
|
||||
// If using the "marker", "expr" or "syntax" method, we
|
||||
// need to continue until the end of the fold is found.
|
||||
if (getlevel == foldlevelMarker
|
||||
|| getlevel == foldlevelExpr
|
||||
|| getlevel == foldlevelSyntax)
|
||||
finish = TRUE;
|
||||
fold_changed = TRUE;
|
||||
|| getlevel == foldlevelSyntax) {
|
||||
finish = true;
|
||||
}
|
||||
fold_changed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2387,12 +2366,11 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *gap, int level,
|
||||
* Check "fp" for safety.
|
||||
*/
|
||||
if (lvl > level && fp != NULL) {
|
||||
/*
|
||||
* There is a nested fold, handle it recursively.
|
||||
*/
|
||||
/* At least do one line (can happen when finish is TRUE). */
|
||||
if (bot < flp->lnum)
|
||||
// There is a nested fold, handle it recursively.
|
||||
// At least do one line (can happen when finish is true).
|
||||
if (bot < flp->lnum) {
|
||||
bot = flp->lnum;
|
||||
}
|
||||
|
||||
/* Line numbers in the nested fold are relative to the start of
|
||||
* this fold. */
|
||||
@ -2454,8 +2432,8 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *gap, int level,
|
||||
/* Current fold at least extends until lnum. */
|
||||
if (fp->fd_len < flp->lnum - fp->fd_top) {
|
||||
fp->fd_len = flp->lnum - fp->fd_top;
|
||||
fp->fd_small = MAYBE;
|
||||
fold_changed = TRUE;
|
||||
fp->fd_small = kNone;
|
||||
fold_changed = true;
|
||||
}
|
||||
|
||||
/* Delete contained folds from the end of the last one found until where
|
||||
@ -2482,8 +2460,9 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *gap, int level,
|
||||
foldSplit(gap, i, flp->lnum, bot);
|
||||
fp = (fold_T *)gap->ga_data + i;
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
fp->fd_len = flp->lnum - fp->fd_top;
|
||||
}
|
||||
fold_changed = true;
|
||||
}
|
||||
}
|
||||
@ -2502,7 +2481,7 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *gap, int level,
|
||||
(linenr_T)MAXLNUM, (long)(fp2->fd_top - flp->lnum));
|
||||
fp2->fd_len -= flp->lnum - fp2->fd_top;
|
||||
fp2->fd_top = flp->lnum;
|
||||
fold_changed = TRUE;
|
||||
fold_changed = true;
|
||||
}
|
||||
|
||||
if (lvl >= level) {
|
||||
@ -2511,8 +2490,8 @@ static linenr_T foldUpdateIEMSRecurse(garray_T *gap, int level,
|
||||
}
|
||||
break;
|
||||
}
|
||||
fold_changed = TRUE;
|
||||
deleteFoldEntry(gap, (int)(fp2 - (fold_T *)gap->ga_data), TRUE);
|
||||
fold_changed = true;
|
||||
deleteFoldEntry(gap, (int)(fp2 - (fold_T *)gap->ga_data), true);
|
||||
}
|
||||
|
||||
/* Need to redraw the lines we inspected, which might be further down than
|
||||
@ -2548,36 +2527,32 @@ static void foldInsert(garray_T *gap, int i)
|
||||
* The caller must first have taken care of any nested folds from "top" to
|
||||
* "bot"!
|
||||
*/
|
||||
static void foldSplit(garray_T *gap, int i, linenr_T top, linenr_T bot)
|
||||
static void foldSplit(garray_T *const gap, const int i, const linenr_T top,
|
||||
const linenr_T bot)
|
||||
{
|
||||
fold_T *fp;
|
||||
fold_T *fp2;
|
||||
garray_T *gap1;
|
||||
garray_T *gap2;
|
||||
int idx;
|
||||
int len;
|
||||
|
||||
/* The fold continues below bot, need to split it. */
|
||||
foldInsert(gap, i + 1);
|
||||
|
||||
fp = (fold_T *)gap->ga_data + i;
|
||||
fold_T *const fp = (fold_T *)gap->ga_data + i;
|
||||
fp[1].fd_top = bot + 1;
|
||||
// check for wrap around (MAXLNUM, and 32bit)
|
||||
assert(fp[1].fd_top > bot);
|
||||
fp[1].fd_len = fp->fd_len - (fp[1].fd_top - fp->fd_top);
|
||||
fp[1].fd_flags = fp->fd_flags;
|
||||
fp[1].fd_small = MAYBE;
|
||||
fp->fd_small = MAYBE;
|
||||
fp[1].fd_small = kNone;
|
||||
fp->fd_small = kNone;
|
||||
|
||||
/* Move nested folds below bot to new fold. There can't be
|
||||
* any between top and bot, they have been removed by the caller. */
|
||||
gap1 = &fp->fd_nested;
|
||||
gap2 = &fp[1].fd_nested;
|
||||
garray_T *const gap1 = &fp->fd_nested;
|
||||
garray_T *const gap2 = &fp[1].fd_nested;
|
||||
(void)(foldFind(gap1, bot + 1 - fp->fd_top, &fp2));
|
||||
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) {
|
||||
ga_grow(gap2, len);
|
||||
for (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].fd_top
|
||||
-= fp[1].fd_top - fp->fd_top;
|
||||
@ -2586,7 +2561,7 @@ static void foldSplit(garray_T *gap, int i, linenr_T top, linenr_T bot)
|
||||
gap1->ga_len -= len;
|
||||
}
|
||||
fp->fd_len = top - fp->fd_top;
|
||||
fold_changed = TRUE;
|
||||
fold_changed = true;
|
||||
}
|
||||
|
||||
/* foldRemove() {{{2 */
|
||||
@ -2848,8 +2823,8 @@ static void foldMerge(fold_T *fp1, garray_T *gap, fold_T *fp2)
|
||||
}
|
||||
|
||||
fp1->fd_len += fp2->fd_len;
|
||||
deleteFoldEntry(gap, (int)(fp2 - (fold_T *)gap->ga_data), TRUE);
|
||||
fold_changed = TRUE;
|
||||
deleteFoldEntry(gap, (int)(fp2 - (fold_T *)gap->ga_data), true);
|
||||
fold_changed = true;
|
||||
}
|
||||
|
||||
/* foldlevelIndent() {{{2 */
|
||||
|
@ -191,7 +191,7 @@ EXTERN int cmdline_star INIT(= FALSE); /* cmdline is crypted */
|
||||
|
||||
EXTERN int exec_from_reg INIT(= FALSE); /* executing register */
|
||||
|
||||
EXTERN int screen_cleared INIT(= FALSE); /* screen has been cleared */
|
||||
EXTERN TriState screen_cleared INIT(= kFalse); // screen has been cleared
|
||||
|
||||
/*
|
||||
* When '$' is included in 'cpoptions' option set:
|
||||
@ -952,9 +952,9 @@ EXTERN char psepcN INIT(= '/'); // abnormal path separator character
|
||||
EXTERN char pseps[2] INIT(= { '\\', 0 }); // normal path separator string
|
||||
#endif
|
||||
|
||||
/* Set to TRUE when an operator is being executed with virtual editing, MAYBE
|
||||
* when no operator is being executed, FALSE otherwise. */
|
||||
EXTERN int virtual_op INIT(= MAYBE);
|
||||
// Set to kTrue when an operator is being executed with virtual editing
|
||||
// kNone when no operator is being executed, kFalse otherwise.
|
||||
EXTERN TriState virtual_op INIT(= kNone);
|
||||
|
||||
/* Display tick, incremented for each call to update_screen() */
|
||||
EXTERN disptick_T display_tick INIT(= 0);
|
||||
|
@ -134,9 +134,9 @@ static int current_syn_id;
|
||||
#define PRCOLOR_BLACK 0
|
||||
#define PRCOLOR_WHITE 0xffffff
|
||||
|
||||
static int curr_italic;
|
||||
static int curr_bold;
|
||||
static int curr_underline;
|
||||
static TriState curr_italic;
|
||||
static TriState curr_bold;
|
||||
static TriState curr_underline;
|
||||
static uint32_t curr_bg;
|
||||
static uint32_t curr_fg;
|
||||
static int page_count;
|
||||
@ -417,7 +417,8 @@ static void prt_set_bg(uint32_t bg)
|
||||
}
|
||||
}
|
||||
|
||||
static void prt_set_font(int bold, int italic, int underline)
|
||||
static void prt_set_font(const TriState bold, const TriState italic,
|
||||
const TriState underline)
|
||||
{
|
||||
if (curr_bold != bold
|
||||
|| curr_italic != italic
|
||||
@ -429,34 +430,32 @@ static void prt_set_font(int bold, int italic, int underline)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Print the line number in the left margin.
|
||||
*/
|
||||
static void prt_line_number(prt_settings_T *psettings, int page_line, linenr_T lnum)
|
||||
// Print the line number in the left margin.
|
||||
static void prt_line_number(prt_settings_T *const psettings,
|
||||
const int page_line, const linenr_T lnum)
|
||||
{
|
||||
int i;
|
||||
char_u tbuf[20];
|
||||
|
||||
prt_set_fg(psettings->number.fg_color);
|
||||
prt_set_bg(psettings->number.bg_color);
|
||||
prt_set_font(psettings->number.bold, psettings->number.italic,
|
||||
psettings->number.underline);
|
||||
mch_print_start_line(TRUE, page_line);
|
||||
mch_print_start_line(true, page_line);
|
||||
|
||||
/* Leave two spaces between the number and the text; depends on
|
||||
* PRINT_NUMBER_WIDTH. */
|
||||
sprintf((char *)tbuf, "%6ld", (long)lnum);
|
||||
for (i = 0; i < 6; i++)
|
||||
// Leave two spaces between the number and the text; depends on
|
||||
// PRINT_NUMBER_WIDTH.
|
||||
char_u tbuf[20];
|
||||
snprintf((char *)tbuf, sizeof(tbuf), "%6ld", (long)lnum);
|
||||
for (int i = 0; i < 6; i++) {
|
||||
(void)mch_print_text_out(&tbuf[i], 1);
|
||||
}
|
||||
|
||||
if (psettings->do_syntax)
|
||||
/* Set colors for next character. */
|
||||
if (psettings->do_syntax) {
|
||||
// Set colors for next character.
|
||||
current_syn_id = -1;
|
||||
else {
|
||||
/* Set colors and font back to normal. */
|
||||
} else {
|
||||
// Set colors and font back to normal.
|
||||
prt_set_fg(PRCOLOR_BLACK);
|
||||
prt_set_bg(PRCOLOR_WHITE);
|
||||
prt_set_font(FALSE, FALSE, FALSE);
|
||||
prt_set_font(kFalse, kFalse, kFalse);
|
||||
}
|
||||
}
|
||||
|
||||
@ -499,22 +498,20 @@ int prt_get_unit(int idx)
|
||||
return u;
|
||||
}
|
||||
|
||||
/*
|
||||
* Print the page header.
|
||||
*/
|
||||
static void prt_header(prt_settings_T *psettings, int pagenum, linenr_T lnum)
|
||||
// Print the page header.
|
||||
static void prt_header(prt_settings_T *const psettings, const int pagenum,
|
||||
const linenr_T lnum)
|
||||
{
|
||||
int width = psettings->chars_per_line;
|
||||
int page_line;
|
||||
char_u *tbuf;
|
||||
char_u *p;
|
||||
|
||||
/* Also use the space for the line number. */
|
||||
if (prt_use_number())
|
||||
// Also use the space for the line number.
|
||||
if (prt_use_number()) {
|
||||
width += PRINT_NUMBER_WIDTH;
|
||||
}
|
||||
|
||||
assert(width >= 0);
|
||||
tbuf = xmalloc((size_t)width + IOSIZE);
|
||||
const size_t tbuf_size = (size_t)width + IOSIZE;
|
||||
char_u *tbuf = xmalloc(tbuf_size);
|
||||
|
||||
if (*p_header != NUL) {
|
||||
linenr_T tmp_lnum, tmp_topline, tmp_botline;
|
||||
@ -543,38 +540,40 @@ static void prt_header(prt_settings_T *psettings, int pagenum, linenr_T lnum)
|
||||
curwin->w_cursor.lnum = tmp_lnum;
|
||||
curwin->w_topline = tmp_topline;
|
||||
curwin->w_botline = tmp_botline;
|
||||
} else
|
||||
sprintf((char *)tbuf, _("Page %d"), pagenum);
|
||||
} else {
|
||||
snprintf((char *)tbuf, tbuf_size, _("Page %d"), pagenum);
|
||||
}
|
||||
|
||||
prt_set_fg(PRCOLOR_BLACK);
|
||||
prt_set_bg(PRCOLOR_WHITE);
|
||||
prt_set_font(TRUE, FALSE, FALSE);
|
||||
prt_set_font(kTrue, kFalse, kFalse);
|
||||
|
||||
/* Use a negative line number to indicate printing in the top margin. */
|
||||
page_line = 0 - prt_header_height();
|
||||
mch_print_start_line(TRUE, page_line);
|
||||
for (p = tbuf; *p != NUL; ) {
|
||||
int l = (*mb_ptr2len)(p);
|
||||
// Use a negative line number to indicate printing in the top margin.
|
||||
int page_line = 0 - prt_header_height();
|
||||
mch_print_start_line(true, page_line);
|
||||
for (char_u *p = tbuf; *p != NUL; ) {
|
||||
const int l = (*mb_ptr2len)(p);
|
||||
assert(l >= 0);
|
||||
if (mch_print_text_out(p, (size_t)l)) {
|
||||
++page_line;
|
||||
if (page_line >= 0) /* out of room in header */
|
||||
page_line++;
|
||||
if (page_line >= 0) { // out of room in header
|
||||
break;
|
||||
mch_print_start_line(TRUE, page_line);
|
||||
}
|
||||
mch_print_start_line(true, page_line);
|
||||
}
|
||||
p += l;
|
||||
}
|
||||
|
||||
xfree(tbuf);
|
||||
|
||||
if (psettings->do_syntax)
|
||||
/* Set colors for next character. */
|
||||
if (psettings->do_syntax) {
|
||||
// Set colors for next character.
|
||||
current_syn_id = -1;
|
||||
else {
|
||||
/* Set colors and font back to normal. */
|
||||
} else {
|
||||
// Set colors and font back to normal.
|
||||
prt_set_fg(PRCOLOR_BLACK);
|
||||
prt_set_bg(PRCOLOR_WHITE);
|
||||
prt_set_font(FALSE, FALSE, FALSE);
|
||||
prt_set_font(kFalse, kFalse, kFalse);
|
||||
}
|
||||
}
|
||||
|
||||
@ -640,21 +639,19 @@ void ex_hardcopy(exarg_T *eap)
|
||||
else
|
||||
settings.do_syntax = settings.has_color;
|
||||
|
||||
/* Set up printing attributes for line numbers */
|
||||
// Set up printing attributes for line numbers
|
||||
settings.number.fg_color = PRCOLOR_BLACK;
|
||||
settings.number.bg_color = PRCOLOR_WHITE;
|
||||
settings.number.bold = FALSE;
|
||||
settings.number.italic = TRUE;
|
||||
settings.number.underline = FALSE;
|
||||
/*
|
||||
* Syntax highlighting of line numbers.
|
||||
*/
|
||||
if (prt_use_number() && settings.do_syntax) {
|
||||
int id;
|
||||
settings.number.bold = kFalse;
|
||||
settings.number.italic = kTrue;
|
||||
settings.number.underline = kFalse;
|
||||
|
||||
id = syn_name2id((char_u *)"LineNr");
|
||||
if (id > 0)
|
||||
// Syntax highlighting of line numbers.
|
||||
if (prt_use_number() && settings.do_syntax) {
|
||||
int id = syn_name2id((char_u *)"LineNr");
|
||||
if (id > 0) {
|
||||
id = syn_get_final_id(id);
|
||||
}
|
||||
|
||||
prt_get_attr(id, &settings.number, settings.modec);
|
||||
}
|
||||
@ -672,13 +669,13 @@ void ex_hardcopy(exarg_T *eap)
|
||||
/* Set colors and font to normal. */
|
||||
curr_bg = 0xffffffff;
|
||||
curr_fg = 0xffffffff;
|
||||
curr_italic = MAYBE;
|
||||
curr_bold = MAYBE;
|
||||
curr_underline = MAYBE;
|
||||
curr_italic = kNone;
|
||||
curr_bold = kNone;
|
||||
curr_underline = kNone;
|
||||
|
||||
prt_set_fg(PRCOLOR_BLACK);
|
||||
prt_set_bg(PRCOLOR_WHITE);
|
||||
prt_set_font(FALSE, FALSE, FALSE);
|
||||
prt_set_font(kFalse, kFalse, kFalse);
|
||||
current_syn_id = -1;
|
||||
|
||||
jobsplit = (printer_opts[OPT_PRINT_JOBSPLIT].present
|
||||
@ -841,7 +838,7 @@ static colnr_T hardcopy_line(prt_settings_T *psettings, int page_line, prt_pos_T
|
||||
tab_spaces = ppos->lead_spaces;
|
||||
}
|
||||
|
||||
mch_print_start_line(0, page_line);
|
||||
mch_print_start_line(false, page_line);
|
||||
line = ml_get(ppos->file_line);
|
||||
|
||||
/*
|
||||
@ -1266,8 +1263,8 @@ static int prt_do_moveto;
|
||||
static int prt_need_font;
|
||||
static int prt_font;
|
||||
static int prt_need_underline;
|
||||
static int prt_underline;
|
||||
static int prt_do_underline;
|
||||
static TriState prt_underline;
|
||||
static TriState prt_do_underline;
|
||||
static int prt_need_fgcol;
|
||||
static uint32_t prt_fgcol;
|
||||
static int prt_need_bgcol;
|
||||
@ -2855,7 +2852,7 @@ int mch_print_begin_page(char_u *str)
|
||||
/* We have reset the font attributes, force setting them again. */
|
||||
curr_bg = 0xffffffff;
|
||||
curr_fg = 0xffffffff;
|
||||
curr_bold = MAYBE;
|
||||
curr_bold = kNone;
|
||||
|
||||
return !prt_file_error;
|
||||
}
|
||||
@ -2868,11 +2865,12 @@ int mch_print_blank_page(void)
|
||||
static double prt_pos_x = 0;
|
||||
static double prt_pos_y = 0;
|
||||
|
||||
void mch_print_start_line(int margin, int page_line)
|
||||
void mch_print_start_line(const bool margin, const int page_line)
|
||||
{
|
||||
prt_pos_x = prt_left_margin;
|
||||
if (margin)
|
||||
if (margin) {
|
||||
prt_pos_x -= prt_number_width;
|
||||
}
|
||||
|
||||
prt_pos_y = prt_top_margin - prt_first_line_height -
|
||||
page_line * prt_line_height;
|
||||
@ -3059,7 +3057,8 @@ int mch_print_text_out(char_u *const textp, size_t len)
|
||||
return need_break;
|
||||
}
|
||||
|
||||
void mch_print_set_font(int iBold, int iItalic, int iUnderline)
|
||||
void mch_print_set_font(const TriState iBold, const TriState iItalic,
|
||||
const TriState iUnderline)
|
||||
{
|
||||
int font = 0;
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h> // for size_t
|
||||
|
||||
#include "nvim/globals.h" // for TriState
|
||||
#include "nvim/types.h" // for char_u
|
||||
#include "nvim/ex_cmds_defs.h" // for exarg_T
|
||||
|
||||
@ -13,9 +14,9 @@
|
||||
typedef struct {
|
||||
uint32_t fg_color;
|
||||
uint32_t bg_color;
|
||||
int bold;
|
||||
int italic;
|
||||
int underline;
|
||||
TriState bold;
|
||||
TriState italic;
|
||||
TriState underline;
|
||||
int undercurl;
|
||||
} prt_text_attr_T;
|
||||
|
||||
|
@ -63,8 +63,8 @@ ex_menu(exarg_T *eap)
|
||||
char_u *p;
|
||||
int i;
|
||||
long pri_tab[MENUDEPTH + 1];
|
||||
int enable = MAYBE; /* TRUE for "menu enable", FALSE for "menu
|
||||
* disable */
|
||||
TriState enable = kNone; // kTrue for "menu enable",
|
||||
// kFalse for "menu disable
|
||||
vimmenu_T menuarg;
|
||||
|
||||
modes = get_menu_cmd_modes(eap->cmd, eap->forceit, &noremap, &unmenu);
|
||||
@ -133,10 +133,10 @@ ex_menu(exarg_T *eap)
|
||||
* Check for "disable" or "enable" argument.
|
||||
*/
|
||||
if (STRNCMP(arg, "enable", 6) == 0 && ascii_iswhite(arg[6])) {
|
||||
enable = TRUE;
|
||||
enable = kTrue;
|
||||
arg = skipwhite(arg + 6);
|
||||
} else if (STRNCMP(arg, "disable", 7) == 0 && ascii_iswhite(arg[7])) {
|
||||
enable = FALSE;
|
||||
enable = kFalse;
|
||||
arg = skipwhite(arg + 7);
|
||||
}
|
||||
|
||||
@ -160,22 +160,21 @@ ex_menu(exarg_T *eap)
|
||||
/*
|
||||
* If there is only a menu name, display menus with that name.
|
||||
*/
|
||||
if (*map_to == NUL && !unmenu && enable == MAYBE) {
|
||||
if (*map_to == NUL && !unmenu && enable == kNone) {
|
||||
show_menus(menu_path, modes);
|
||||
goto theend;
|
||||
} else if (*map_to != NUL && (unmenu || enable != MAYBE)) {
|
||||
} else if (*map_to != NUL && (unmenu || enable != kNone)) {
|
||||
EMSG(_(e_trailing));
|
||||
goto theend;
|
||||
}
|
||||
|
||||
if (enable != MAYBE) {
|
||||
/*
|
||||
* Change sensitivity of the menu.
|
||||
* For the PopUp menu, remove a menu for each mode separately.
|
||||
* Careful: menu_nable_recurse() changes menu_path.
|
||||
*/
|
||||
if (STRCMP(menu_path, "*") == 0) /* meaning: do all menus */
|
||||
if (enable != kNone) {
|
||||
// Change sensitivity of the menu.
|
||||
// For the PopUp menu, remove a menu for each mode separately.
|
||||
// Careful: menu_nable_recurse() changes menu_path.
|
||||
if (STRCMP(menu_path, "*") == 0) { // meaning: do all menus
|
||||
menu_path = (char_u *)"";
|
||||
}
|
||||
|
||||
if (menu_is_popup(menu_path)) {
|
||||
for (i = 0; i < MENU_INDEX_TIP; ++i)
|
||||
|
@ -1203,16 +1203,15 @@ int get_last_leader_offset(char_u *line, char_u **flags)
|
||||
/*
|
||||
* Return the number of window lines occupied by buffer line "lnum".
|
||||
*/
|
||||
int plines(linenr_T lnum)
|
||||
int plines(const linenr_T lnum)
|
||||
{
|
||||
return plines_win(curwin, lnum, TRUE);
|
||||
return plines_win(curwin, lnum, true);
|
||||
}
|
||||
|
||||
int
|
||||
plines_win (
|
||||
win_T *wp,
|
||||
linenr_T lnum,
|
||||
int winheight /* when TRUE limit to window height */
|
||||
int plines_win(
|
||||
win_T *const wp,
|
||||
const linenr_T lnum,
|
||||
const bool winheight // when true limit to window height
|
||||
)
|
||||
{
|
||||
/* Check for filler lines above this buffer line. When folded the result
|
||||
@ -1220,34 +1219,34 @@ plines_win (
|
||||
return plines_win_nofill(wp, lnum, winheight) + diff_check_fill(wp, lnum);
|
||||
}
|
||||
|
||||
int plines_nofill(linenr_T lnum)
|
||||
int plines_nofill(const linenr_T lnum)
|
||||
{
|
||||
return plines_win_nofill(curwin, lnum, TRUE);
|
||||
return plines_win_nofill(curwin, lnum, true);
|
||||
}
|
||||
|
||||
int
|
||||
plines_win_nofill (
|
||||
win_T *wp,
|
||||
linenr_T lnum,
|
||||
int winheight /* when TRUE limit to window height */
|
||||
int plines_win_nofill(
|
||||
win_T *const wp,
|
||||
const linenr_T lnum,
|
||||
const bool winheight // when true limit to window height
|
||||
)
|
||||
{
|
||||
int lines;
|
||||
|
||||
if (!wp->w_p_wrap)
|
||||
if (!wp->w_p_wrap) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (wp->w_width == 0)
|
||||
if (wp->w_width == 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* A folded lines is handled just like an empty line. */
|
||||
/* NOTE: Caller must handle lines that are MAYBE folded. */
|
||||
if (lineFolded(wp, lnum) == TRUE)
|
||||
// A folded lines is handled just like an empty line.
|
||||
if (lineFolded(wp, lnum)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
lines = plines_win_nofold(wp, lnum);
|
||||
if (winheight > 0 && lines > wp->w_height)
|
||||
const int lines = plines_win_nofold(wp, lnum);
|
||||
if (winheight && lines > wp->w_height) {
|
||||
return wp->w_height;
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
@ -1347,11 +1346,12 @@ int plines_m_win(win_T *wp, linenr_T first, linenr_T last)
|
||||
++count; /* count 1 for "+-- folded" line */
|
||||
first += x;
|
||||
} else {
|
||||
if (first == wp->w_topline)
|
||||
count += plines_win_nofill(wp, first, TRUE) + wp->w_topfill;
|
||||
else
|
||||
count += plines_win(wp, first, TRUE);
|
||||
++first;
|
||||
if (first == wp->w_topline) {
|
||||
count += plines_win_nofill(wp, first, true) + wp->w_topfill;
|
||||
} else {
|
||||
count += plines_win(wp, first, true);
|
||||
}
|
||||
first++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
|
@ -2015,7 +2015,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
|
||||
default:
|
||||
clearopbeep(oap);
|
||||
}
|
||||
virtual_op = MAYBE;
|
||||
virtual_op = kNone;
|
||||
if (!gui_yank) {
|
||||
/*
|
||||
* if 'sol' not set, go back to old column for some commands
|
||||
@ -2090,7 +2090,7 @@ static void op_colon(oparg_T *oap)
|
||||
*/
|
||||
static void op_function(oparg_T *oap)
|
||||
{
|
||||
int save_virtual_op = virtual_op;
|
||||
const TriState save_virtual_op = virtual_op;
|
||||
|
||||
if (*p_opfunc == NUL)
|
||||
EMSG(_("E774: 'operatorfunc' is empty"));
|
||||
@ -2113,7 +2113,7 @@ static void op_function(oparg_T *oap)
|
||||
|
||||
// Reset virtual_op so that 'virtualedit' can be changed in the
|
||||
// function.
|
||||
virtual_op = MAYBE;
|
||||
virtual_op = kNone;
|
||||
|
||||
(void)call_func_retnr(p_opfunc, 1, argv, false);
|
||||
|
||||
|
@ -5383,7 +5383,7 @@ void cursor_pos_info(dict_T *dict)
|
||||
case Ctrl_V:
|
||||
virtual_op = virtual_active();
|
||||
block_prep(&oparg, &bd, lnum, 0);
|
||||
virtual_op = MAYBE;
|
||||
virtual_op = kNone;
|
||||
s = bd.textstart;
|
||||
len = (long)bd.textlen;
|
||||
break;
|
||||
|
@ -783,17 +783,19 @@ static void win_update(win_T *wp)
|
||||
}
|
||||
}
|
||||
|
||||
(void)hasFoldingWin(wp, mod_top, &mod_top, NULL, TRUE, NULL);
|
||||
if (mod_top > lnumt)
|
||||
(void)hasFoldingWin(wp, mod_top, &mod_top, NULL, true, NULL);
|
||||
if (mod_top > lnumt) {
|
||||
mod_top = lnumt;
|
||||
}
|
||||
|
||||
/* Now do the same for the bottom line (one above mod_bot). */
|
||||
--mod_bot;
|
||||
(void)hasFoldingWin(wp, mod_bot, NULL, &mod_bot, TRUE, NULL);
|
||||
++mod_bot;
|
||||
if (mod_bot < lnumb)
|
||||
// Now do the same for the bottom line (one above mod_bot).
|
||||
mod_bot--;
|
||||
(void)hasFoldingWin(wp, mod_bot, NULL, &mod_bot, true, NULL);
|
||||
mod_bot++;
|
||||
if (mod_bot < lnumb) {
|
||||
mod_bot = lnumb;
|
||||
}
|
||||
}
|
||||
|
||||
/* When a change starts above w_topline and the end is below
|
||||
* w_topline, start redrawing at w_topline.
|
||||
@ -833,12 +835,13 @@ static void win_update(win_T *wp)
|
||||
type = VALID;
|
||||
}
|
||||
|
||||
/* Trick: we want to avoid clearing the screen twice. screenclear() will
|
||||
* set "screen_cleared" to TRUE. The special value MAYBE (which is still
|
||||
* non-zero and thus not FALSE) will indicate that screenclear() was not
|
||||
* called. */
|
||||
if (screen_cleared)
|
||||
screen_cleared = MAYBE;
|
||||
// Trick: we want to avoid clearing the screen twice. screenclear() will
|
||||
// set "screen_cleared" to kTrue. The special value kNone (which is still
|
||||
// non-zero and thus not kFalse) will indicate that screenclear() was not
|
||||
// called.
|
||||
if (screen_cleared) {
|
||||
screen_cleared = kNone;
|
||||
}
|
||||
|
||||
/*
|
||||
* If there are no changes on the screen that require a complete redraw,
|
||||
@ -875,7 +878,7 @@ static void win_update(win_T *wp)
|
||||
++j;
|
||||
if (j >= wp->w_height - 2)
|
||||
break;
|
||||
(void)hasFoldingWin(wp, ln, NULL, &ln, TRUE, NULL);
|
||||
(void)hasFoldingWin(wp, ln, NULL, &ln, true, NULL);
|
||||
}
|
||||
} else
|
||||
j = wp->w_lines[0].wl_lnum - wp->w_topline;
|
||||
@ -987,7 +990,7 @@ static void win_update(win_T *wp)
|
||||
* when it won't get updated below. */
|
||||
if (wp->w_p_diff && bot_start > 0)
|
||||
wp->w_lines[0].wl_size =
|
||||
plines_win_nofill(wp, wp->w_topline, TRUE)
|
||||
plines_win_nofill(wp, wp->w_topline, true)
|
||||
+ wp->w_topfill;
|
||||
}
|
||||
}
|
||||
@ -999,23 +1002,26 @@ static void win_update(win_T *wp)
|
||||
if (mid_start == 0) {
|
||||
mid_end = wp->w_height;
|
||||
if (ONE_WINDOW) {
|
||||
/* Clear the screen when it was not done by win_del_lines() or
|
||||
* win_ins_lines() above, "screen_cleared" is FALSE or MAYBE
|
||||
* then. */
|
||||
if (screen_cleared != TRUE)
|
||||
// Clear the screen when it was not done by win_del_lines() or
|
||||
// win_ins_lines() above, "screen_cleared" is kFalse or kNone
|
||||
// then.
|
||||
if (screen_cleared != kTrue) {
|
||||
screenclear();
|
||||
/* The screen was cleared, redraw the tab pages line. */
|
||||
if (redraw_tabline)
|
||||
}
|
||||
// The screen was cleared, redraw the tab pages line.
|
||||
if (redraw_tabline) {
|
||||
draw_tabline();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* When win_del_lines() or win_ins_lines() caused the screen to be
|
||||
* cleared (only happens for the first window) or when screenclear()
|
||||
* was called directly above, "must_redraw" will have been set to
|
||||
* NOT_VALID, need to reset it here to avoid redrawing twice. */
|
||||
if (screen_cleared == TRUE)
|
||||
if (screen_cleared == kTrue) {
|
||||
must_redraw = 0;
|
||||
}
|
||||
} else {
|
||||
/* Not VALID or INVERTED: redraw all lines. */
|
||||
mid_start = 0;
|
||||
@ -1303,15 +1309,15 @@ static void win_update(win_T *wp)
|
||||
/* Able to count old number of rows: Count new window
|
||||
* rows, and may insert/delete lines */
|
||||
j = idx;
|
||||
for (l = lnum; l < mod_bot; ++l) {
|
||||
if (hasFoldingWin(wp, l, NULL, &l, TRUE, NULL))
|
||||
++new_rows;
|
||||
else if (l == wp->w_topline)
|
||||
new_rows += plines_win_nofill(wp, l, TRUE)
|
||||
+ wp->w_topfill;
|
||||
else
|
||||
new_rows += plines_win(wp, l, TRUE);
|
||||
++j;
|
||||
for (l = lnum; l < mod_bot; l++) {
|
||||
if (hasFoldingWin(wp, l, NULL, &l, true, NULL)) {
|
||||
new_rows++;
|
||||
} else if (l == wp->w_topline) {
|
||||
new_rows += plines_win_nofill(wp, l, true) + wp->w_topfill;
|
||||
} else {
|
||||
new_rows += plines_win(wp, l, true);
|
||||
}
|
||||
j++;
|
||||
if (new_rows > wp->w_height - row - 2) {
|
||||
/* it's getting too much, must redraw the rest */
|
||||
new_rows = 9999;
|
||||
@ -1441,12 +1447,13 @@ static void win_update(win_T *wp)
|
||||
}
|
||||
|
||||
wp->w_lines[idx].wl_lnum = lnum;
|
||||
wp->w_lines[idx].wl_valid = TRUE;
|
||||
if (row > wp->w_height) { /* past end of screen */
|
||||
/* we may need the size of that too long line later on */
|
||||
if (dollar_vcol == -1)
|
||||
wp->w_lines[idx].wl_size = plines_win(wp, lnum, TRUE);
|
||||
++idx;
|
||||
wp->w_lines[idx].wl_valid = true;
|
||||
if (row > wp->w_height) { // past end of screen
|
||||
// we may need the size of that too long line later on
|
||||
if (dollar_vcol == -1) {
|
||||
wp->w_lines[idx].wl_size = plines_win(wp, lnum, true);
|
||||
}
|
||||
idx++;
|
||||
break;
|
||||
}
|
||||
if (dollar_vcol == -1)
|
||||
@ -5520,11 +5527,13 @@ static void prepare_search_hl(win_T *wp, linenr_T lnum)
|
||||
&& re_multiline(shl->rm.regprog)) {
|
||||
if (shl->first_lnum == 0) {
|
||||
for (shl->first_lnum = lnum;
|
||||
shl->first_lnum > wp->w_topline; --shl->first_lnum)
|
||||
if (hasFoldingWin(wp, shl->first_lnum - 1,
|
||||
NULL, NULL, TRUE, NULL))
|
||||
shl->first_lnum > wp->w_topline;
|
||||
shl->first_lnum--) {
|
||||
if (hasFoldingWin(wp, shl->first_lnum - 1, NULL, NULL, true, NULL)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cur != NULL) {
|
||||
cur->pos.cur = 0;
|
||||
}
|
||||
@ -6067,7 +6076,7 @@ static void screenclear2(void)
|
||||
ui_call_grid_clear(1); // clear the display
|
||||
clear_cmdline = false;
|
||||
mode_displayed = false;
|
||||
screen_cleared = true; // can use contents of ScreenLines now
|
||||
screen_cleared = kTrue; // can use contents of ScreenLines now
|
||||
|
||||
win_rest_invalid(firstwin);
|
||||
redraw_cmdline = TRUE;
|
||||
|
@ -1549,37 +1549,31 @@ static bool find_rawstring_end(char_u *linep, pos_T *startpos, pos_T *endpos)
|
||||
|
||||
pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel)
|
||||
{
|
||||
static pos_T pos; /* current search position */
|
||||
int findc = 0; /* matching brace */
|
||||
int c;
|
||||
int count = 0; /* cumulative number of braces */
|
||||
int backwards = false; /* init for gcc */
|
||||
int raw_string = false; /* search for raw string */
|
||||
int inquote = false; /* true when inside quotes */
|
||||
char_u *linep; /* pointer to current line */
|
||||
static pos_T pos; // current search position
|
||||
int findc = 0; // matching brace
|
||||
int count = 0; // cumulative number of braces
|
||||
int backwards = false; // init for gcc
|
||||
bool raw_string = false; // search for raw string
|
||||
bool inquote = false; // true when inside quotes
|
||||
char_u *ptr;
|
||||
int do_quotes; /* check for quotes in current line */
|
||||
int at_start; /* do_quotes value at start position */
|
||||
int hash_dir = 0; /* Direction searched for # things */
|
||||
int comment_dir = 0; /* Direction searched for comments */
|
||||
pos_T match_pos; /* Where last slash-star was found */
|
||||
int start_in_quotes; /* start position is in quotes */
|
||||
int traveled = 0; /* how far we've searched so far */
|
||||
int ignore_cend = FALSE; /* ignore comment end */
|
||||
int cpo_match; /* vi compatible matching */
|
||||
int cpo_bsl; /* don't recognize backslashes */
|
||||
int match_escaped = 0; /* search for escaped match */
|
||||
int dir; /* Direction to search */
|
||||
int comment_col = MAXCOL; /* start of / / comment */
|
||||
int lispcomm = FALSE; /* inside of Lisp-style comment */
|
||||
int lisp = curbuf->b_p_lisp; /* engage Lisp-specific hacks ;) */
|
||||
int hash_dir = 0; // Direction searched for # things
|
||||
int comment_dir = 0; // Direction searched for comments
|
||||
int traveled = 0; // how far we've searched so far
|
||||
bool ignore_cend = false; // ignore comment end
|
||||
int match_escaped = 0; // search for escaped match
|
||||
int dir; // Direction to search
|
||||
int comment_col = MAXCOL; // start of / / comment
|
||||
bool lispcomm = false; // inside of Lisp-style comment
|
||||
bool lisp = curbuf->b_p_lisp; // engage Lisp-specific hacks ;)
|
||||
|
||||
pos = curwin->w_cursor;
|
||||
pos.coladd = 0;
|
||||
linep = ml_get(pos.lnum);
|
||||
char_u *linep = ml_get(pos.lnum); // pointer to current line
|
||||
|
||||
cpo_match = (vim_strchr(p_cpo, CPO_MATCH) != NULL);
|
||||
cpo_bsl = (vim_strchr(p_cpo, CPO_MATCHBSL) != NULL);
|
||||
// vi compatible matching
|
||||
bool cpo_match = (vim_strchr(p_cpo, CPO_MATCH) != NULL);
|
||||
// don't recognize backslashes
|
||||
bool cpo_bsl = (vim_strchr(p_cpo, CPO_MATCHBSL) != NULL);
|
||||
|
||||
/* Direction to search when initc is '/', '*' or '#' */
|
||||
if (flags & FM_BACKWARD)
|
||||
@ -1748,13 +1742,16 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel)
|
||||
}
|
||||
}
|
||||
|
||||
/* This is just guessing: when 'rightleft' is set, search for a matching
|
||||
* paren/brace in the other direction. */
|
||||
if (curwin->w_p_rl && vim_strchr((char_u *)"()[]{}<>", initc) != NULL)
|
||||
// This is just guessing: when 'rightleft' is set, search for a matching
|
||||
// paren/brace in the other direction.
|
||||
if (curwin->w_p_rl && vim_strchr((char_u *)"()[]{}<>", initc) != NULL) {
|
||||
backwards = !backwards;
|
||||
}
|
||||
|
||||
do_quotes = -1;
|
||||
start_in_quotes = MAYBE;
|
||||
int do_quotes = -1; // check for quotes in current line
|
||||
int at_start; // do_quotes value at start position
|
||||
TriState start_in_quotes = kNone; // start position is in quotes
|
||||
pos_T match_pos; // Where last slash-star was found
|
||||
clearpos(&match_pos);
|
||||
|
||||
/* backward search: Check if this line contains a single-line comment */
|
||||
@ -1762,8 +1759,9 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel)
|
||||
|| lisp
|
||||
)
|
||||
comment_col = check_linecomment(linep);
|
||||
if (lisp && comment_col != MAXCOL && pos.col > (colnr_T)comment_col)
|
||||
lispcomm = TRUE; /* find match inside this comment */
|
||||
if (lisp && comment_col != MAXCOL && pos.col > (colnr_T)comment_col) {
|
||||
lispcomm = true; // find match inside this comment
|
||||
}
|
||||
while (!got_int) {
|
||||
/*
|
||||
* Go to the next position, forward or backward. We could use
|
||||
@ -1925,26 +1923,29 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel)
|
||||
* one for a '\' at the end.
|
||||
*/
|
||||
if (!do_quotes) {
|
||||
inquote = FALSE;
|
||||
inquote = false;
|
||||
if (ptr[-1] == '\\') {
|
||||
do_quotes = 1;
|
||||
if (start_in_quotes == MAYBE) {
|
||||
/* Do we need to use at_start here? */
|
||||
inquote = TRUE;
|
||||
start_in_quotes = TRUE;
|
||||
} else if (backwards)
|
||||
inquote = TRUE;
|
||||
if (start_in_quotes == kNone) {
|
||||
// Do we need to use at_start here?
|
||||
inquote = true;
|
||||
start_in_quotes = kTrue;
|
||||
} else if (backwards) {
|
||||
inquote = true;
|
||||
}
|
||||
}
|
||||
if (pos.lnum > 1) {
|
||||
ptr = ml_get(pos.lnum - 1);
|
||||
if (*ptr && *(ptr + STRLEN(ptr) - 1) == '\\') {
|
||||
do_quotes = 1;
|
||||
if (start_in_quotes == MAYBE) {
|
||||
if (start_in_quotes == kNone) {
|
||||
inquote = at_start;
|
||||
if (inquote)
|
||||
start_in_quotes = TRUE;
|
||||
} else if (!backwards)
|
||||
inquote = TRUE;
|
||||
if (inquote) {
|
||||
start_in_quotes = kTrue;
|
||||
}
|
||||
} else if (!backwards) {
|
||||
inquote = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* ml_get() only keeps one line, need to get linep again */
|
||||
@ -1952,8 +1953,9 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (start_in_quotes == MAYBE)
|
||||
start_in_quotes = FALSE;
|
||||
if (start_in_quotes == kNone) {
|
||||
start_in_quotes = kFalse;
|
||||
}
|
||||
|
||||
/*
|
||||
* If 'smartmatch' is set:
|
||||
@ -1966,13 +1968,13 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel)
|
||||
* inquote if the number of quotes in a line is even, unless this
|
||||
* line or the previous one ends in a '\'. Complicated, isn't it?
|
||||
*/
|
||||
c = PTR2CHAR(linep + pos.col);
|
||||
const int c = PTR2CHAR(linep + pos.col);
|
||||
switch (c) {
|
||||
case NUL:
|
||||
/* at end of line without trailing backslash, reset inquote */
|
||||
if (pos.col == 0 || linep[pos.col - 1] != '\\') {
|
||||
inquote = FALSE;
|
||||
start_in_quotes = FALSE;
|
||||
inquote = false;
|
||||
start_in_quotes = kFalse;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1987,7 +1989,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel)
|
||||
break;
|
||||
if ((((int)pos.col - 1 - col) & 1) == 0) {
|
||||
inquote = !inquote;
|
||||
start_in_quotes = FALSE;
|
||||
start_in_quotes = kFalse;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -2039,7 +2041,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel)
|
||||
|
||||
/* Check for match outside of quotes, and inside of
|
||||
* quotes when the start is also inside of quotes. */
|
||||
if ((!inquote || start_in_quotes == TRUE)
|
||||
if ((!inquote || start_in_quotes == kTrue)
|
||||
&& (c == initc || c == findc)) {
|
||||
int col, bslcnt = 0;
|
||||
|
||||
|
@ -73,13 +73,13 @@ getkey:
|
||||
}
|
||||
}
|
||||
|
||||
/// Return TRUE if in the current mode we need to use virtual.
|
||||
int virtual_active(void)
|
||||
/// Return true if in the current mode we need to use virtual.
|
||||
bool virtual_active(void)
|
||||
{
|
||||
// While an operator is being executed we return "virtual_op", because
|
||||
// VIsual_active has already been reset, thus we can't check for "block"
|
||||
// being used.
|
||||
if (virtual_op != MAYBE) {
|
||||
if (virtual_op != kNone) {
|
||||
return virtual_op;
|
||||
}
|
||||
return ve_flags == VE_ALL
|
||||
|
@ -4848,8 +4848,8 @@ void scroll_to_fraction(win_T *wp, int prev_height)
|
||||
sline = wp->w_wrow - line_size;
|
||||
|
||||
if (sline >= 0) {
|
||||
/* Make sure the whole cursor line is visible, if possible. */
|
||||
int rows = plines_win(wp, lnum, FALSE);
|
||||
// Make sure the whole cursor line is visible, if possible.
|
||||
const int rows = plines_win(wp, lnum, false);
|
||||
|
||||
if (sline > wp->w_height - rows) {
|
||||
sline = wp->w_height - rows;
|
||||
@ -4884,12 +4884,13 @@ void scroll_to_fraction(win_T *wp, int prev_height)
|
||||
--sline;
|
||||
break;
|
||||
}
|
||||
--lnum;
|
||||
if (lnum == wp->w_topline)
|
||||
line_size = plines_win_nofill(wp, lnum, TRUE)
|
||||
lnum--;
|
||||
if (lnum == wp->w_topline) {
|
||||
line_size = plines_win_nofill(wp, lnum, true)
|
||||
+ wp->w_topfill;
|
||||
else
|
||||
line_size = plines_win(wp, lnum, TRUE);
|
||||
} else {
|
||||
line_size = plines_win(wp, lnum, true);
|
||||
}
|
||||
sline -= line_size;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user