mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
pos: define MAXCOL to INT_MAX
Partial port of patch v8.1.0953. Remove useless casts on MAXCOL.
This commit is contained in:
parent
ceed85ea43
commit
ab5083b5fc
@ -708,7 +708,7 @@ int ptr2cells(const char_u *p)
|
|||||||
/// @return number of character cells.
|
/// @return number of character cells.
|
||||||
int vim_strsize(char_u *s)
|
int vim_strsize(char_u *s)
|
||||||
{
|
{
|
||||||
return vim_strnsize(s, (int)MAXCOL);
|
return vim_strnsize(s, MAXCOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the number of character cells string "s[len]" will take on the
|
/// Return the number of character cells string "s[len]" will take on the
|
||||||
|
@ -1627,11 +1627,11 @@ static void init_prompt(int cmdchar_todo)
|
|||||||
ml_append(curbuf->b_ml.ml_line_count, prompt, 0, false);
|
ml_append(curbuf->b_ml.ml_line_count, prompt, 0, false);
|
||||||
}
|
}
|
||||||
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
|
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
|
||||||
coladvance((colnr_T)MAXCOL);
|
coladvance(MAXCOL);
|
||||||
changed_bytes(curbuf->b_ml.ml_line_count, 0);
|
changed_bytes(curbuf->b_ml.ml_line_count, 0);
|
||||||
}
|
}
|
||||||
if (cmdchar_todo == 'A') {
|
if (cmdchar_todo == 'A') {
|
||||||
coladvance((colnr_T)MAXCOL);
|
coladvance(MAXCOL);
|
||||||
}
|
}
|
||||||
if (cmdchar_todo == 'I' || curwin->w_cursor.col <= (int)STRLEN(prompt)) {
|
if (cmdchar_todo == 'I' || curwin->w_cursor.col <= (int)STRLEN(prompt)) {
|
||||||
curwin->w_cursor.col = STRLEN(prompt);
|
curwin->w_cursor.col = STRLEN(prompt);
|
||||||
@ -6246,9 +6246,10 @@ void auto_format(
|
|||||||
if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) {
|
if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) {
|
||||||
// "cannot happen"
|
// "cannot happen"
|
||||||
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
|
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
|
||||||
coladvance((colnr_T)MAXCOL);
|
coladvance(MAXCOL);
|
||||||
} else
|
} else {
|
||||||
check_cursor_col();
|
check_cursor_col();
|
||||||
|
}
|
||||||
|
|
||||||
// Insert mode: If the cursor is now after the end of the line while it
|
// Insert mode: If the cursor is now after the end of the line while it
|
||||||
// previously wasn't, the line was broken. Because of the rule above we
|
// previously wasn't, the line was broken. Because of the rule above we
|
||||||
@ -8432,8 +8433,8 @@ static void ins_left(void)
|
|||||||
// if 'whichwrap' set for cursor in insert mode may go to previous line.
|
// if 'whichwrap' set for cursor in insert mode may go to previous line.
|
||||||
// always break undo when moving upwards/downwards, else undo may break
|
// always break undo when moving upwards/downwards, else undo may break
|
||||||
start_arrow(&tpos);
|
start_arrow(&tpos);
|
||||||
--(curwin->w_cursor.lnum);
|
curwin->w_cursor.lnum--;
|
||||||
coladvance((colnr_T)MAXCOL);
|
coladvance(MAXCOL);
|
||||||
curwin->w_set_curswant = true; // so we stay at the end
|
curwin->w_set_curswant = true; // so we stay at the end
|
||||||
} else {
|
} else {
|
||||||
vim_beep(BO_CRSR);
|
vim_beep(BO_CRSR);
|
||||||
@ -8467,7 +8468,7 @@ static void ins_end(int c)
|
|||||||
tpos = curwin->w_cursor;
|
tpos = curwin->w_cursor;
|
||||||
if (c == K_C_END)
|
if (c == K_C_END)
|
||||||
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
|
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
|
||||||
coladvance((colnr_T)MAXCOL);
|
coladvance(MAXCOL);
|
||||||
curwin->w_curswant = MAXCOL;
|
curwin->w_curswant = MAXCOL;
|
||||||
|
|
||||||
start_arrow(&tpos);
|
start_arrow(&tpos);
|
||||||
|
@ -4198,7 +4198,7 @@ skip:
|
|||||||
// when interactive leave cursor on the match
|
// when interactive leave cursor on the match
|
||||||
if (!subflags.do_ask) {
|
if (!subflags.do_ask) {
|
||||||
if (endcolumn) {
|
if (endcolumn) {
|
||||||
coladvance((colnr_T)MAXCOL);
|
coladvance(MAXCOL);
|
||||||
} else {
|
} else {
|
||||||
beginline(BL_WHITE | BL_FIX);
|
beginline(BL_WHITE | BL_FIX);
|
||||||
}
|
}
|
||||||
@ -5020,7 +5020,7 @@ int find_help_tags(const char_u *arg, int *num_matches, char_u ***matches,
|
|||||||
if (keep_lang) {
|
if (keep_lang) {
|
||||||
flags |= TAG_KEEP_LANG;
|
flags |= TAG_KEEP_LANG;
|
||||||
}
|
}
|
||||||
if (find_tags(IObuff, num_matches, matches, flags, (int)MAXCOL, NULL) == OK
|
if (find_tags(IObuff, num_matches, matches, flags, MAXCOL, NULL) == OK
|
||||||
&& *num_matches > 0) {
|
&& *num_matches > 0) {
|
||||||
/* Sort the matches found on the heuristic number that is after the
|
/* Sort the matches found on the heuristic number that is after the
|
||||||
* tag name. */
|
* tag name. */
|
||||||
|
@ -6774,6 +6774,6 @@ static void set_search_match(pos_T *t)
|
|||||||
t->col = search_match_endcol;
|
t->col = search_match_endcol;
|
||||||
if (t->lnum > curbuf->b_ml.ml_line_count) {
|
if (t->lnum > curbuf->b_ml.ml_line_count) {
|
||||||
t->lnum = curbuf->b_ml.ml_line_count;
|
t->lnum = curbuf->b_ml.ml_line_count;
|
||||||
coladvance((colnr_T)MAXCOL);
|
coladvance(MAXCOL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4142,7 +4142,7 @@ void goto_byte(long cnt)
|
|||||||
if (lnum < 1) { // past the end
|
if (lnum < 1) { // past the end
|
||||||
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
|
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
|
||||||
curwin->w_curswant = MAXCOL;
|
curwin->w_curswant = MAXCOL;
|
||||||
coladvance((colnr_T)MAXCOL);
|
coladvance(MAXCOL);
|
||||||
} else {
|
} else {
|
||||||
curwin->w_cursor.lnum = lnum;
|
curwin->w_cursor.lnum = lnum;
|
||||||
curwin->w_cursor.col = (colnr_T)boff;
|
curwin->w_cursor.col = (colnr_T)boff;
|
||||||
|
@ -412,7 +412,7 @@ int plines_win_nofold(win_T *wp, linenr_T lnum)
|
|||||||
s = ml_get_buf(wp->w_buffer, lnum, FALSE);
|
s = ml_get_buf(wp->w_buffer, lnum, FALSE);
|
||||||
if (*s == NUL) /* empty line */
|
if (*s == NUL) /* empty line */
|
||||||
return 1;
|
return 1;
|
||||||
col = win_linetabsize(wp, s, (colnr_T)MAXCOL);
|
col = win_linetabsize(wp, s, MAXCOL);
|
||||||
|
|
||||||
// If list mode is on, then the '$' at the end of the line may take up one
|
// If list mode is on, then the '$' at the end of the line may take up one
|
||||||
// extra column.
|
// extra column.
|
||||||
|
@ -5225,16 +5225,13 @@ static void nv_left(cmdarg_T *cap)
|
|||||||
* 'h' wraps to previous line if 'whichwrap' has 'h'.
|
* 'h' wraps to previous line if 'whichwrap' has 'h'.
|
||||||
* CURS_LEFT wraps to previous line if 'whichwrap' has '<'.
|
* CURS_LEFT wraps to previous line if 'whichwrap' has '<'.
|
||||||
*/
|
*/
|
||||||
if ( (((cap->cmdchar == K_BS
|
if ((((cap->cmdchar == K_BS || cap->cmdchar == Ctrl_H)
|
||||||
|| cap->cmdchar == Ctrl_H)
|
&& vim_strchr(p_ww, 'b') != NULL)
|
||||||
&& vim_strchr(p_ww, 'b') != NULL)
|
|| (cap->cmdchar == 'h' && vim_strchr(p_ww, 'h') != NULL)
|
||||||
|| (cap->cmdchar == 'h'
|
|| (cap->cmdchar == K_LEFT && vim_strchr(p_ww, '<') != NULL))
|
||||||
&& vim_strchr(p_ww, 'h') != NULL)
|
&& curwin->w_cursor.lnum > 1) {
|
||||||
|| (cap->cmdchar == K_LEFT
|
curwin->w_cursor.lnum--;
|
||||||
&& vim_strchr(p_ww, '<') != NULL))
|
coladvance(MAXCOL);
|
||||||
&& curwin->w_cursor.lnum > 1) {
|
|
||||||
--(curwin->w_cursor.lnum);
|
|
||||||
coladvance((colnr_T)MAXCOL);
|
|
||||||
curwin->w_set_curswant = true;
|
curwin->w_set_curswant = true;
|
||||||
|
|
||||||
// When the NL before the first char has to be deleted we
|
// When the NL before the first char has to be deleted we
|
||||||
@ -6471,7 +6468,7 @@ static void nv_visual(cmdarg_T *cap)
|
|||||||
}
|
}
|
||||||
if (resel_VIsual_vcol == MAXCOL) {
|
if (resel_VIsual_vcol == MAXCOL) {
|
||||||
curwin->w_curswant = MAXCOL;
|
curwin->w_curswant = MAXCOL;
|
||||||
coladvance((colnr_T)MAXCOL);
|
coladvance(MAXCOL);
|
||||||
} else if (VIsual_mode == Ctrl_V) {
|
} else if (VIsual_mode == Ctrl_V) {
|
||||||
validate_virtcol();
|
validate_virtcol();
|
||||||
assert(cap->count0 >= INT_MIN && cap->count0 <= INT_MAX);
|
assert(cap->count0 >= INT_MIN && cap->count0 <= INT_MAX);
|
||||||
@ -7610,7 +7607,7 @@ void set_cursor_for_append_to_line(void)
|
|||||||
// Pretend Insert mode here to allow the cursor on the
|
// Pretend Insert mode here to allow the cursor on the
|
||||||
// character past the end of the line
|
// character past the end of the line
|
||||||
State = INSERT;
|
State = INSERT;
|
||||||
coladvance((colnr_T)MAXCOL);
|
coladvance(MAXCOL);
|
||||||
State = save_State;
|
State = save_State;
|
||||||
} else {
|
} else {
|
||||||
curwin->w_cursor.col += (colnr_T)STRLEN(get_cursor_pos_ptr());
|
curwin->w_cursor.col += (colnr_T)STRLEN(get_cursor_pos_ptr());
|
||||||
@ -7998,7 +7995,7 @@ static void nv_put_opt(cmdarg_T *cap, bool fix_indent)
|
|||||||
* line. */
|
* line. */
|
||||||
if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) {
|
if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) {
|
||||||
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
|
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
|
||||||
coladvance((colnr_T)MAXCOL);
|
coladvance(MAXCOL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto_format(false, true);
|
auto_format(false, true);
|
||||||
|
@ -4305,11 +4305,12 @@ format_lines(
|
|||||||
* tabs and spaces, according to current options */
|
* tabs and spaces, according to current options */
|
||||||
(void)set_indent(get_indent(), SIN_CHANGED);
|
(void)set_indent(get_indent(), SIN_CHANGED);
|
||||||
|
|
||||||
/* put cursor on last non-space */
|
// put cursor on last non-space
|
||||||
State = NORMAL; /* don't go past end-of-line */
|
State = NORMAL; // don't go past end-of-line
|
||||||
coladvance((colnr_T)MAXCOL);
|
coladvance(MAXCOL);
|
||||||
while (curwin->w_cursor.col && ascii_isspace(gchar_cursor()))
|
while (curwin->w_cursor.col && ascii_isspace(gchar_cursor())) {
|
||||||
dec_cursor();
|
dec_cursor();
|
||||||
|
}
|
||||||
|
|
||||||
/* do the formatting, without 'showmode' */
|
/* do the formatting, without 'showmode' */
|
||||||
State = INSERT; /* for open_line() */
|
State = INSERT; /* for open_line() */
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#ifndef NVIM_POS_H
|
#ifndef NVIM_POS_H
|
||||||
#define NVIM_POS_H
|
#define NVIM_POS_H
|
||||||
|
|
||||||
|
// for INT_MAX, LONG_MAX et al.
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
typedef long linenr_T; // line number type
|
typedef long linenr_T; // line number type
|
||||||
/// Format used to print values which have linenr_T type
|
/// Format used to print values which have linenr_T type
|
||||||
#define PRIdLINENR "ld"
|
#define PRIdLINENR "ld"
|
||||||
@ -12,8 +15,8 @@ typedef int colnr_T;
|
|||||||
|
|
||||||
/// Maximal (invalid) line number
|
/// Maximal (invalid) line number
|
||||||
enum { MAXLNUM = 0x7fffffff };
|
enum { MAXLNUM = 0x7fffffff };
|
||||||
/// Maximal column number, 31 bits
|
/// Maximal column number
|
||||||
enum { MAXCOL = 0x7fffffff };
|
enum { MAXCOL = INT_MAX };
|
||||||
// Minimum line number
|
// Minimum line number
|
||||||
enum { MINLNUM = 1 };
|
enum { MINLNUM = 1 };
|
||||||
// minimum column number
|
// minimum column number
|
||||||
|
@ -2685,8 +2685,9 @@ fwd_word(
|
|||||||
while (--count >= 0) {
|
while (--count >= 0) {
|
||||||
/* When inside a range of folded lines, move to the last char of the
|
/* When inside a range of folded lines, move to the last char of the
|
||||||
* last line. */
|
* last line. */
|
||||||
if (hasFolding(curwin->w_cursor.lnum, NULL, &curwin->w_cursor.lnum))
|
if (hasFolding(curwin->w_cursor.lnum, NULL, &curwin->w_cursor.lnum)) {
|
||||||
coladvance((colnr_T)MAXCOL);
|
coladvance(MAXCOL);
|
||||||
|
}
|
||||||
sclass = cls();
|
sclass = cls();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2803,8 +2804,9 @@ int end_word(long count, int bigword, int stop, int empty)
|
|||||||
while (--count >= 0) {
|
while (--count >= 0) {
|
||||||
/* When inside a range of folded lines, move to the last char of the
|
/* When inside a range of folded lines, move to the last char of the
|
||||||
* last line. */
|
* last line. */
|
||||||
if (hasFolding(curwin->w_cursor.lnum, NULL, &curwin->w_cursor.lnum))
|
if (hasFolding(curwin->w_cursor.lnum, NULL, &curwin->w_cursor.lnum)) {
|
||||||
coladvance((colnr_T)MAXCOL);
|
coladvance(MAXCOL);
|
||||||
|
}
|
||||||
sclass = cls();
|
sclass = cls();
|
||||||
if (inc_cursor() == -1)
|
if (inc_cursor() == -1)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
@ -3152,7 +3152,7 @@ int get_tags(list_T *list, char_u *pat, char_u *buf_fname)
|
|||||||
bool is_static;
|
bool is_static;
|
||||||
|
|
||||||
ret = find_tags(pat, &num_matches, &matches,
|
ret = find_tags(pat, &num_matches, &matches,
|
||||||
TAG_REGEXP | TAG_NOIC, (int)MAXCOL, buf_fname);
|
TAG_REGEXP | TAG_NOIC, MAXCOL, buf_fname);
|
||||||
if (ret == OK && num_matches > 0) {
|
if (ret == OK && num_matches > 0) {
|
||||||
for (i = 0; i < num_matches; ++i) {
|
for (i = 0; i < num_matches; ++i) {
|
||||||
int parse_result = parse_match(matches[i], &tp);
|
int parse_result = parse_match(matches[i], &tp);
|
||||||
|
Loading…
Reference in New Issue
Block a user