diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/nvim/api/vim.c | 11 | ||||
-rw-r--r-- | src/nvim/buffer_defs.h | 5 | ||||
-rw-r--r-- | src/nvim/charset.c | 5 | ||||
-rw-r--r-- | src/nvim/cursor_shape.c | 2 | ||||
-rw-r--r-- | src/nvim/digraph.c | 2 | ||||
-rw-r--r-- | src/nvim/edit.c | 41 | ||||
-rw-r--r-- | src/nvim/eval.c | 11 | ||||
-rw-r--r-- | src/nvim/ex_cmds2.c | 3 | ||||
-rw-r--r-- | src/nvim/ex_eval.c | 6 | ||||
-rw-r--r-- | src/nvim/ex_getln.c | 32 | ||||
-rw-r--r-- | src/nvim/file_search.c | 37 | ||||
-rw-r--r-- | src/nvim/getchar.c | 5 | ||||
-rw-r--r-- | src/nvim/globals.h | 4 | ||||
-rw-r--r-- | src/nvim/indent_c.c | 47 | ||||
-rw-r--r-- | src/nvim/mbyte.c | 21 | ||||
-rw-r--r-- | src/nvim/misc2.c | 4 | ||||
-rw-r--r-- | src/nvim/normal.c | 28 | ||||
-rw-r--r-- | src/nvim/option.c | 20 | ||||
-rw-r--r-- | src/nvim/option_defs.h | 4 | ||||
-rw-r--r-- | src/nvim/screen.c | 6 | ||||
-rw-r--r-- | src/nvim/search.c | 2 | ||||
-rw-r--r-- | src/nvim/testdir/test_listlbr.in | 8 | ||||
-rw-r--r-- | src/nvim/testdir/test_listlbr.ok | 4 | ||||
-rw-r--r-- | src/nvim/ui.c | 49 | ||||
-rw-r--r-- | src/nvim/version.c | 12 |
26 files changed, 131 insertions, 242 deletions
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index a2d052c4ec..3b05c7329c 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -48,17 +48,14 @@ set(CONV_SOURCES ex_cmds2.c ex_cmds.c ex_docmd.c - ex_eval.c ex_getln.c farsi.c fileio.c - file_search.c fold.c getchar.c hardcopy.c if_cscope.c indent.c - indent_c.c keymap.c main.c mark.c @@ -76,7 +73,6 @@ set(CONV_SOURCES popupmnu.c quickfix.c regexp.c - regexp_nfa.c screen.c search.c sha256.c diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index fc1307090d..fe5fa6274b 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -207,12 +207,11 @@ ArrayOf(String) vim_list_runtime_paths(void) rv.items[i].type = kObjectTypeString; rv.items[i].data.string.data = xmalloc(MAXPATHL); // Copy the path from 'runtimepath' to rv.items[i] - int length = copy_option_part(&rtp, - (char_u *)rv.items[i].data.string.data, - MAXPATHL, - ","); - assert(length >= 0); - rv.items[i].data.string.size = (size_t)length; + size_t length = copy_option_part(&rtp, + (char_u *)rv.items[i].data.string.data, + MAXPATHL, + ","); + rv.items[i].data.string.size = length; } return rv; diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index 196b975d2a..23f20c3c75 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -578,12 +578,7 @@ struct file_buffer { #define B_IMODE_USE_INSERT -1 /* Use b_p_iminsert value for search */ #define B_IMODE_NONE 0 /* Input via none */ #define B_IMODE_LMAP 1 /* Input via langmap */ -#ifndef USE_IM_CONTROL # define B_IMODE_LAST 1 -#else -# define B_IMODE_IM 2 /* Input via input method */ -# define B_IMODE_LAST 2 -#endif short b_kmap_state; /* using "lmap" mappings */ # define KEYMAP_INIT 1 /* 'keymap' was set, call keymap_init() */ diff --git a/src/nvim/charset.c b/src/nvim/charset.c index f3bb3d8c73..bbe80a519c 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -1058,6 +1058,11 @@ int win_lbr_chartabsize(win_T *wp, char_u *line, char_u *s, colnr_T col, int *he if (col >= (colnr_T)wp->w_width) { col -= wp->w_width; numberextra = wp->w_width - (numberextra - win_col_off2(wp)); + if (*p_sbr != NUL) { + colnr_T sbrlen = (colnr_T)MB_CHARLEN(p_sbr); + if (col >= sbrlen) + col -= sbrlen; + } if (numberextra > 0) { col = col % numberextra; } diff --git a/src/nvim/cursor_shape.c b/src/nvim/cursor_shape.c index 06c8186bf9..87064b4ef3 100644 --- a/src/nvim/cursor_shape.c +++ b/src/nvim/cursor_shape.c @@ -135,7 +135,7 @@ char_u *parse_shape_opt(int what) p += len; if (!VIM_ISDIGIT(*p)) return (char_u *)N_("E548: digit expected"); - long digits = getdigits(&p); + int64_t digits = getdigits(&p); assert(digits <= INT_MAX); int n = (int)digits; if (len == 3) { /* "ver" or "hor" */ diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c index 440d07aab0..6587a43452 100644 --- a/src/nvim/digraph.c +++ b/src/nvim/digraph.c @@ -1611,7 +1611,7 @@ void putdigraph(char_u *str) EMSG(_(e_number_exp)); return; } - long digits = getdigits(&str); + int64_t digits = getdigits(&str); assert(digits <= INT_MAX); int n = (int)digits; diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 2cc91a2591..c7f20783a9 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -391,9 +391,6 @@ edit ( */ if (curbuf->b_p_iminsert == B_IMODE_LMAP) State |= LANGMAP; -#ifdef USE_IM_CONTROL - im_set_active(curbuf->b_p_iminsert == B_IMODE_IM); -#endif setmouse(); clear_showcmd(); @@ -5081,6 +5078,10 @@ internal_format ( colnr_T leader_len; int no_leader = FALSE; int do_comments = (flags & INSCHAR_DO_COM); + int has_lbr = curwin->w_p_lbr; + + // make sure win_lbr_chartabsize() counts correctly + curwin->w_p_lbr = false; /* * When 'ai' is off we don't want a space under the cursor to be @@ -5370,6 +5371,8 @@ internal_format ( if (save_char != NUL) /* put back space after cursor */ pchar_cursor(save_char); + curwin->w_p_lbr = has_lbr; + if (!format_only && haveto_redraw) { update_topline(); redraw_curbuf_later(VALID); @@ -6758,19 +6761,11 @@ static void ins_reg(void) * message for it. Only call it explicitly. */ ++no_u_sync; if (regname == '=') { -# ifdef USE_IM_CONTROL - int im_on = im_get_status(); -# endif /* Sync undo when evaluating the expression calls setline() or * append(), so that it can be undone separately. */ u_sync_once = 2; regname = get_expr_register(); -# ifdef USE_IM_CONTROL - /* Restore the Input Method. */ - if (im_on) - im_set_active(TRUE); -# endif } if (regname == NUL || !valid_yank_reg(regname, FALSE)) { vim_beep(); @@ -6867,24 +6862,8 @@ static void ins_ctrl_hat(void) } else { curbuf->b_p_iminsert = B_IMODE_LMAP; State |= LANGMAP; -#ifdef USE_IM_CONTROL - im_set_active(FALSE); -#endif - } - } -#ifdef USE_IM_CONTROL - else { - /* There are no ":lmap" mappings, toggle IM */ - if (im_get_status()) { - curbuf->b_p_iminsert = B_IMODE_NONE; - im_set_active(FALSE); - } else { - curbuf->b_p_iminsert = B_IMODE_IM; - State &= ~LANGMAP; - im_set_active(TRUE); } } -#endif set_iminsert_global(); showmode(); /* Show/unshow value of 'keymap' in status lines. */ @@ -6984,14 +6963,6 @@ ins_esc ( } } -#ifdef USE_IM_CONTROL - /* Disable IM to allow typing English directly for Normal mode commands. - * When ":lmap" is enabled don't change 'iminsert' (IM can be enabled as - * well). */ - if (!(State & LANGMAP)) - im_save_status(&curbuf->b_p_iminsert); - im_set_active(FALSE); -#endif State = NORMAL; /* need to position cursor again (e.g. when on a TAB ) */ diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 34990a62e0..8be25bc34e 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -10631,10 +10631,10 @@ static void f_jobsend(typval_T *argvars, typval_T *rettv) ssize_t input_len; char *input = (char *) save_tv_as_string(&argvars[1], &input_len, true); - if (input_len < 0) { - return; // Error handled by save_tv_as_string(). - } else if (input_len == 0) { - return; // Not an error, but nothing to do. + if (!input) { + // Either the error has been handled by save_tv_as_string(), or there is no + // input to send. + return; } WBuffer *buf = wstream_new_buffer(input, input_len, 1, free); @@ -14559,7 +14559,8 @@ static void get_system_output_as_rettv(typval_T *argvars, typval_T *rettv, // get input to the shell command (if any), and its length ssize_t input_len; char *input = (char *) save_tv_as_string(&argvars[1], &input_len, false); - if (input_len == -1) { + if (input_len < 0) { + assert(input == NULL); return; } diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 96410897df..24a1ccf85d 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -2116,7 +2116,8 @@ int do_in_runtimepath(char_u *name, int all, DoInRuntimepathCB callback, np = name; while (*np != NUL && (all || !did_one)) { /* Append the pattern from "name" to buf[]. */ - copy_option_part(&np, tail, (int)(MAXPATHL - (tail - buf)), + assert(MAXPATHL >= (tail - buf)); + copy_option_part(&np, tail, (size_t)(MAXPATHL - (tail - buf)), "\t "); if (p_verbose > 2) { diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index fba0b93253..ef3facb18b 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -11,6 +11,7 @@ */ #include <assert.h> #include <stdbool.h> +#include <stdint.h> #include <inttypes.h> #include "nvim/vim.h" @@ -1307,7 +1308,7 @@ void ex_catch(exarg_T *eap) int skip = FALSE; int caught = FALSE; char_u *end; - int save_char = 0; + char_u save_char = 0; char_u *save_cpo; regmatch_T regmatch; int prev_got_int; @@ -1530,7 +1531,8 @@ void ex_finally(exarg_T *eap) pending |= did_throw ? CSTP_THROW : 0; pending |= did_emsg ? CSTP_ERROR : 0; pending |= got_int ? CSTP_INTERRUPT : 0; - cstack->cs_pending[cstack->cs_idx] = pending; + assert(pending >= CHAR_MIN && pending <= CHAR_MAX); + cstack->cs_pending[cstack->cs_idx] = (char)pending; /* It's mandatory that the current exception is stored in the * cstack so that it can be rethrown at the ":endtry" or be diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index a19423532d..70db2dc479 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -265,14 +265,7 @@ getcmdline ( b_im_ptr = &curbuf->b_p_imsearch; if (*b_im_ptr == B_IMODE_LMAP) State |= LANGMAP; -#ifdef USE_IM_CONTROL - im_set_active(*b_im_ptr == B_IMODE_IM); -#endif } -#ifdef USE_IM_CONTROL - else if (p_imcmdline) - im_set_active(TRUE); -#endif setmouse(); ui_cursor_shape(); /* may show different cursor shape */ @@ -867,9 +860,6 @@ getcmdline ( if (map_to_exists_mode((char_u *)"", LANGMAP, FALSE)) { /* ":lmap" mappings exists, toggle use of mappings. */ State ^= LANGMAP; -#ifdef USE_IM_CONTROL - im_set_active(FALSE); /* Disable input method */ -#endif if (b_im_ptr != NULL) { if (State & LANGMAP) *b_im_ptr = B_IMODE_LMAP; @@ -877,23 +867,6 @@ getcmdline ( *b_im_ptr = B_IMODE_NONE; } } -#ifdef USE_IM_CONTROL - else { - /* There are no ":lmap" mappings, toggle IM. When - * 'imdisable' is set don't try getting the status, it's - * always off. */ - if ((p_imdisable && b_im_ptr != NULL) - ? *b_im_ptr == B_IMODE_IM : im_get_status()) { - im_set_active(FALSE); /* Disable input method */ - if (b_im_ptr != NULL) - *b_im_ptr = B_IMODE_NONE; - } else { - im_set_active(TRUE); /* Enable input method */ - if (b_im_ptr != NULL) - *b_im_ptr = B_IMODE_IM; - } - } -#endif if (b_im_ptr != NULL) { if (b_im_ptr == &curbuf->b_p_iminsert) set_iminsert_global(); @@ -1542,11 +1515,6 @@ returncmd: need_wait_return = FALSE; State = save_State; -#ifdef USE_IM_CONTROL - if (b_im_ptr != NULL && *b_im_ptr != B_IMODE_LMAP) - im_save_status(b_im_ptr); - im_set_active(FALSE); -#endif setmouse(); ui_cursor_shape(); /* may show different cursor shape */ diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c index 1cb9e1e8f7..a51f088586 100644 --- a/src/nvim/file_search.c +++ b/src/nvim/file_search.c @@ -44,10 +44,13 @@ * functions. */ +#include <assert.h> #include <errno.h> #include <string.h> #include <stdbool.h> +#include <stdint.h> #include <inttypes.h> +#include <limits.h> #include "nvim/vim.h" #include "nvim/ascii.h" @@ -355,12 +358,11 @@ vim_findfile_init ( */ if (stopdirs != NULL) { char_u *walker = stopdirs; - int dircount; while (*walker == ';') walker++; - dircount = 1; + size_t dircount = 1; search_ctx->ffsc_stopdirs_v = xmalloc(sizeof(char_u *)); do { @@ -397,7 +399,7 @@ vim_findfile_init ( */ wc_part = vim_strchr(path, '*'); if (wc_part != NULL) { - int llevel; + int64_t llevel; int len; char *errpt; @@ -425,7 +427,7 @@ vim_findfile_init ( llevel = strtol((char *)wc_part, &errpt, 10); if ((char_u *)errpt != wc_part && llevel > 0 && llevel < 255) - ff_expand_buffer[len++] = llevel; + ff_expand_buffer[len++] = (char_u)llevel; else if ((char_u *)errpt != wc_part && llevel == 0) /* restrict is 0 -> remove already added '**' */ len -= 2; @@ -580,8 +582,7 @@ char_u *vim_findfile(void *search_ctx_arg) char_u *rest_of_wildcards; char_u *path_end = NULL; ff_stack_T *stackp; - int len; - int i; + size_t len; char_u *p; char_u *suf; ff_search_ctx_T *search_ctx; @@ -701,7 +702,7 @@ char_u *vim_findfile(void *search_ctx_arg) rest_of_wildcards = stackp->ffs_wc_path; if (*rest_of_wildcards != NUL) { - len = (int)STRLEN(file_path); + len = STRLEN(file_path); if (STRNCMP(rest_of_wildcards, "**", 2) == 0) { /* pointer to the restrict byte * The restrict byte is not a character! @@ -772,7 +773,7 @@ char_u *vim_findfile(void *search_ctx_arg) * We don't have further wildcards to expand, so we have to * check for the final file now. */ - for (i = stackp->ffs_filearray_cur; + for (int i = stackp->ffs_filearray_cur; i < stackp->ffs_filearray_size; ++i) { if (!path_with_url(stackp->ffs_filearray[i]) && !os_isdir(stackp->ffs_filearray[i])) @@ -788,7 +789,7 @@ char_u *vim_findfile(void *search_ctx_arg) * Try without extra suffix and then with suffixes * from 'suffixesadd'. */ - len = (int)STRLEN(file_path); + len = STRLEN(file_path); if (search_ctx->ffsc_tagfile) suf = (char_u *)""; else @@ -829,7 +830,8 @@ char_u *vim_findfile(void *search_ctx_arg) #endif /* push dir to examine rest of subdirs later */ - stackp->ffs_filearray_cur = i + 1; + assert(i < UCHAR_MAX - 1); + stackp->ffs_filearray_cur = (char_u)(i + 1); ff_push(search_ctx, stackp); if (!path_with_url(file_path)) @@ -856,6 +858,7 @@ char_u *vim_findfile(void *search_ctx_arg) /* Not found or found already, try next suffix. */ if (*suf == NUL) break; + assert(MAXPATHL >= len); copy_option_part(&suf, file_path + len, MAXPATHL - len, ","); } @@ -865,7 +868,7 @@ char_u *vim_findfile(void *search_ctx_arg) * still wildcards left, push the directories for further * search */ - for (i = stackp->ffs_filearray_cur; + for (int i = stackp->ffs_filearray_cur; i < stackp->ffs_filearray_size; ++i) { if (!os_isdir(stackp->ffs_filearray[i])) continue; /* not a directory */ @@ -886,7 +889,7 @@ char_u *vim_findfile(void *search_ctx_arg) * leaves of the directory tree. */ if (STRNCMP(stackp->ffs_wc_path, "**", 2) == 0) { - for (i = stackp->ffs_filearray_cur; + for (int i = stackp->ffs_filearray_cur; i < stackp->ffs_filearray_size; ++i) { if (fnamecmp(stackp->ffs_filearray[i], stackp->ffs_fix_path) == 0) @@ -1397,9 +1400,6 @@ find_file_in_path_option ( * filename on the first call. */ if (first == TRUE) { - int l; - int run; - if (path_with_url(ff_file_to_find)) { file_name = vim_strsave(ff_file_to_find); goto theend; @@ -1407,8 +1407,8 @@ find_file_in_path_option ( /* When FNAME_REL flag given first use the directory of the file. * Otherwise or when this fails use the current directory. */ - for (run = 1; run <= 2; ++run) { - l = (int)STRLEN(ff_file_to_find); + for (int run = 1; run <= 2; ++run) { + size_t l = STRLEN(ff_file_to_find); if (run == 1 && rel_to_curdir && (options & FNAME_REL) @@ -1416,7 +1416,7 @@ find_file_in_path_option ( && STRLEN(rel_fname) + l < MAXPATHL) { STRCPY(NameBuff, rel_fname); STRCPY(path_tail(NameBuff), ff_file_to_find); - l = (int)STRLEN(NameBuff); + l = STRLEN(NameBuff); } else { STRCPY(NameBuff, ff_file_to_find); run = 2; @@ -1436,6 +1436,7 @@ find_file_in_path_option ( } if (*buf == NUL) break; + assert(MAXPATHL >= l); copy_option_part(&buf, NameBuff + l, MAXPATHL - l, ","); } } diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 6c70773fcf..d0bdcde9e8 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -2349,11 +2349,6 @@ static int vgetorpeek(int advance) + typebuf.tb_len] != NUL) typebuf.tb_noremap[typebuf.tb_off + typebuf.tb_len++] = RM_YES; -#ifdef USE_IM_CONTROL - /* Get IM status right after getting keys, not after the - * timeout for a mapping (focus may be lost by then). */ - vgetc_im_active = im_get_status(); -#endif } } /* for (;;) */ } /* if (!character from stuffbuf) */ diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 2d8e511ade..ea91135194 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -897,10 +897,6 @@ EXTERN int stop_insert_mode; /* for ":stopinsert" and 'insertmode' */ EXTERN int KeyTyped; /* TRUE if user typed current char */ EXTERN int KeyStuffed; /* TRUE if current char from stuffbuf */ -#ifdef USE_IM_CONTROL -EXTERN int vgetc_im_active; /* Input Method was active for last - character obtained from vgetc() */ -#endif EXTERN int maptick INIT(= 0); /* tick for each non-mapped char */ EXTERN char_u chartab[256]; /* table used in charset.c; See diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c index 509f94dbf2..82f9194fa7 100644 --- a/src/nvim/indent_c.c +++ b/src/nvim/indent_c.c @@ -1,4 +1,6 @@ +#include <assert.h> #include <inttypes.h> +#include <stdint.h> #include "nvim/vim.h" #include "nvim/ascii.h" @@ -37,7 +39,7 @@ find_start_comment ( /* XXX */ pos_T *pos; char_u *line; char_u *p; - int cur_maxcomment = ind_maxcomment; + int64_t cur_maxcomment = ind_maxcomment; for (;; ) { pos = findmatchlimit(NULL, '*', FM_BACKWARD, cur_maxcomment); @@ -115,27 +117,25 @@ static char_u *skip_string(char_u *p) /* - * Return TRUE if the string "line" starts with a word from 'cinwords'. + * Return true if the string "line" starts with a word from 'cinwords'. */ -int cin_is_cinword(char_u *line) +bool cin_is_cinword(char_u *line) { - char_u *cinw; - char_u *cinw_buf; - int cinw_len; - int retval = FALSE; - int len; + bool retval = false; - cinw_len = (int)STRLEN(curbuf->b_p_cinw) + 1; - cinw_buf = xmalloc(cinw_len); + size_t cinw_len = STRLEN(curbuf->b_p_cinw) + 1; + char_u *cinw_buf = xmalloc(cinw_len); line = skipwhite(line); - for (cinw = curbuf->b_p_cinw; *cinw; ) { - len = copy_option_part(&cinw, cinw_buf, cinw_len, ","); + + for (char_u *cinw = curbuf->b_p_cinw; *cinw; ) { + size_t len = copy_option_part(&cinw, cinw_buf, cinw_len, ","); if (STRNCMP(line, cinw_buf, len) == 0 && (!vim_iswordc(line[len]) || !vim_iswordc(line[len - 1]))) { - retval = TRUE; + retval = true; break; } } + free(cinw_buf); return retval; @@ -662,7 +662,7 @@ static int cin_islinecomment(char_u *p) * Return the character terminating the line (ending char's have precedence if * both apply in order to determine initializations). */ -static int +static char_u cin_isterminated ( char_u *s, int incl_open, /* include '{' at the end as terminator */ @@ -1281,8 +1281,6 @@ void parse_cino(buf_T *buf) { char_u *p; char_u *l; - char_u *digits; - int n; int divider; int fraction = 0; int sw = (int)get_sw_value(buf); @@ -1415,11 +1413,13 @@ void parse_cino(buf_T *buf) l = p++; if (*p == '-') ++p; - digits = p; /* remember where the digits start */ - n = getdigits(&p); + char_u *digits_start = p; /* remember where the digits start */ + int64_t digits = getdigits(&p); + assert(digits <= INT_MAX); + int n = (int)digits; divider = 0; if (*p == '.') { /* ".5s" means a fraction */ - fraction = atol((char *)++p); + fraction = atoi((char *)++p); while (VIM_ISDIGIT(*p)) { ++p; if (divider) @@ -1429,7 +1429,7 @@ void parse_cino(buf_T *buf) } } if (*p == 's') { /* "2s" means two times 'shiftwidth' */ - if (p == digits) + if (p == digits_start) n = sw; /* just "s" is one 'shiftwidth' */ else { n *= sw; @@ -1625,8 +1625,11 @@ int get_c_indent(void) what = *p++; else if (*p == COM_LEFT || *p == COM_RIGHT) align = *p++; - else if (VIM_ISDIGIT(*p) || *p == '-') - off = getdigits(&p); + else if (VIM_ISDIGIT(*p) || *p == '-') { + int64_t digits = getdigits(&p); + assert(digits <= INT_MAX); + off = (int)digits; + } else ++p; } diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 2240c1fe83..d79a46ceaa 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -103,7 +103,6 @@ #include "nvim/screen.h" #include "nvim/spell.h" #include "nvim/strings.h" -#include "nvim/ui.h" #include "nvim/os/os.h" #include "nvim/arabic.h" @@ -3972,3 +3971,23 @@ char_u * string_convert_ext(vimconv_T *vcp, char_u *ptr, int *lenp, return retval; } + +// Check bounds for column number +static int check_col(int col) +{ + if (col < 0) + return 0; + if (col >= (int)screen_Columns) + return (int)screen_Columns - 1; + return col; +} + +// Check bounds for row number +static int check_row(int row) +{ + if (row < 0) + return 0; + if (row >= (int)screen_Rows) + return (int)screen_Rows - 1; + return row; +} diff --git a/src/nvim/misc2.c b/src/nvim/misc2.c index acf243b349..bc65056b21 100644 --- a/src/nvim/misc2.c +++ b/src/nvim/misc2.c @@ -167,9 +167,9 @@ int csh_like_shell(void) * "*option" is advanced to the next part. * The length is returned. */ -int copy_option_part(char_u **option, char_u *buf, int maxlen, char *sep_chars) +size_t copy_option_part(char_u **option, char_u *buf, size_t maxlen, char *sep_chars) { - int len = 0; + size_t len = 0; char_u *p = *option; /* skip '.' at start of option part, for 'suffixes' */ diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 5202354199..0a43d59607 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -717,9 +717,6 @@ getcount: bool lit = false; /* get extra character literally */ bool langmap_active = false; /* using :lmap mappings */ int lang; /* getting a text character */ -#ifdef USE_IM_CONTROL - bool save_smd; /* saved value of p_smd */ -#endif ++no_mapping; ++allow_keys; /* no mapping for nchar, but allow key codes */ @@ -768,12 +765,6 @@ getcount: State = LANGMAP; langmap_active = true; } -#ifdef USE_IM_CONTROL - save_smd = p_smd; - p_smd = false; /* Don't let the IM code show the mode here */ - if (lang && curbuf->b_p_iminsert == B_IMODE_IM) - im_set_active(true); -#endif *cp = plain_vgetc(); @@ -783,14 +774,6 @@ getcount: ++allow_keys; State = NORMAL_BUSY; } -#ifdef USE_IM_CONTROL - if (lang) { - if (curbuf->b_p_iminsert != B_IMODE_LMAP) - im_save_status(&curbuf->b_p_iminsert); - im_set_active(false); - } - p_smd = save_smd; -#endif State = NORMAL_BUSY; need_flushbuf |= add_to_showcmd(*cp); @@ -1108,6 +1091,10 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) pos_T old_cursor; bool empty_region_error; int restart_edit_save; + int lbr_saved = curwin->w_p_lbr; + + curwin->w_p_lbr = false; /* avoid a problem with unwanted linebreaks in + * block mode */ /* The visual area is remembered for redo */ static int redo_VIsual_mode = NUL; /* 'v', 'V', or Ctrl-V */ @@ -1720,6 +1707,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) oap->block_mode = false; clearop(oap); } + curwin->w_p_lbr = lbr_saved; } /* @@ -3501,7 +3489,11 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist) * screenline or move two screenlines. */ validate_virtcol(); - if (curwin->w_virtcol > curwin->w_curswant + colnr_T virtcol = curwin->w_virtcol; + if (virtcol > (colnr_T)width1 && *p_sbr != NUL) + virtcol -= vim_strsize(p_sbr); + + if (virtcol > curwin->w_curswant && (curwin->w_curswant < (colnr_T)width1 ? (curwin->w_curswant > (colnr_T)width1 / 2) : ((curwin->w_curswant - width1) % width2 diff --git a/src/nvim/option.c b/src/nvim/option.c index 1d3281e952..ee70b5bf8a 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -912,18 +912,10 @@ static struct vimoption (char_u *)NULL, PV_NONE, {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, {"imcmdline", "imc", P_BOOL|P_VI_DEF, -#ifdef USE_IM_CONTROL - (char_u *)&p_imcmdline, PV_NONE, -#else (char_u *)NULL, PV_NONE, -#endif {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, {"imdisable", "imd", P_BOOL|P_VI_DEF, -#ifdef USE_IM_CONTROL - (char_u *)&p_imdisable, PV_NONE, -#else (char_u *)NULL, PV_NONE, -#endif {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, {"iminsert", "imi", P_NUM|P_VI_DEF, @@ -5134,18 +5126,6 @@ set_bool_option ( foldUpdateAll(curwin); } -#ifdef USE_IM_CONTROL - /* 'imdisable' */ - else if ((int *)varp == &p_imdisable) { - /* Only de-activate it here, it will be enabled when changing mode. */ - if (p_imdisable) - im_set_active(FALSE); - else if (State & INSERT) - /* When the option is set from an autocommand, it may need to take - * effect right away. */ - im_set_active(curbuf->b_p_iminsert == B_IMODE_IM); - } -#endif /* 'spell' */ else if ((int *)varp == &curwin->w_p_spell) { diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index cd61b6427c..89264f8982 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -416,10 +416,6 @@ EXTERN int p_arshape; /* 'arabicshape' */ EXTERN int p_icon; /* 'icon' */ EXTERN char_u *p_iconstring; /* 'iconstring' */ EXTERN int p_ic; /* 'ignorecase' */ -#ifdef USE_IM_CONTROL -EXTERN int p_imcmdline; /* 'imcmdline' */ -EXTERN int p_imdisable; /* 'imdisable' */ -#endif EXTERN int p_is; /* 'incsearch' */ EXTERN int p_im; /* 'insertmode' */ EXTERN char_u *p_isf; /* 'isfname' */ diff --git a/src/nvim/screen.c b/src/nvim/screen.c index bb26066526..2dbf3f8888 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -1205,8 +1205,13 @@ static void win_update(win_T *wp) */ if (VIsual_mode == Ctrl_V) { colnr_T fromc, toc; + int save_ve_flags = ve_flags; + + if (curwin->w_p_lbr) + ve_flags = VE_ALL; getvcols(wp, &VIsual, &curwin->w_cursor, &fromc, &toc); + ve_flags = save_ve_flags; ++toc; if (curwin->w_curswant == MAXCOL) toc = MAXCOL; @@ -3725,6 +3730,7 @@ win_line ( * special character (via 'listchars' option "precedes:<char>". */ if (lcs_prec_todo != NUL + && wp->w_p_list && (wp->w_p_wrap ? wp->w_skipcol > 0 : wp->w_leftcol > 0) && filler_todo <= 0 && draw_state > WL_NR diff --git a/src/nvim/search.c b/src/nvim/search.c index 78d9dcbccb..e9184d84cd 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -1430,7 +1430,7 @@ static int check_prevcol(char_u *linep, int col, int ch, int *prevcol) * NULL */ -pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int maxtravel) +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 */ diff --git a/src/nvim/testdir/test_listlbr.in b/src/nvim/testdir/test_listlbr.in index 2f28126554..75b06b4cc7 100644 --- a/src/nvim/testdir/test_listlbr.in +++ b/src/nvim/testdir/test_listlbr.in @@ -56,6 +56,14 @@ STARTTEST :syn match All /.*/ contains=ConcealVar :let line=ScreenChar(winwidth(0)) :call DoRecordScreen() +:set cpo&vim linebreak +:let g:test ="Test 6: set linebreak with visual block mode" +:let line="REMOVE: this not" +:$put =line +:let line="REMOVE: aaaaaaaaaaaaa" +:$put =line +:1/^REMOVE: +0jf x:$put :%w! test.out :qa! ENDTEST diff --git a/src/nvim/testdir/test_listlbr.ok b/src/nvim/testdir/test_listlbr.ok index 9b8037f4d3..ee74667661 100644 --- a/src/nvim/testdir/test_listlbr.ok +++ b/src/nvim/testdir/test_listlbr.ok @@ -32,3 +32,7 @@ Sabbbbbb bla ~ ~ ~ +this not +aaaaaaaaaaaaa +REMOVE: +REMOVE: diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 0b68eb3051..eab6251288 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -102,52 +102,3 @@ void ui_cursor_shape(void) conceal_check_cursur_line(); } -/* - * Check bounds for column number - */ -int check_col(int col) -{ - if (col < 0) - return 0; - if (col >= (int)screen_Columns) - return (int)screen_Columns - 1; - return col; -} - -/* - * Check bounds for row number - */ -int check_row(int row) -{ - if (row < 0) - return 0; - if (row >= (int)screen_Rows) - return (int)screen_Rows - 1; - return row; -} - - -#if defined(USE_IM_CONTROL) || defined(PROTO) -/* - * Save current Input Method status to specified place. - */ -void im_save_status(long *psave) -{ - /* Don't save when 'imdisable' is set or "xic" is NULL, IM is always - * disabled then (but might start later). - * Also don't save when inside a mapping, vgetc_im_active has not been set - * then. - * And don't save when the keys were stuffed (e.g., for a "." command). - * And don't save when the GUI is running but our window doesn't have - * input focus (e.g., when a find dialog is open). */ - if (!p_imdisable && KeyTyped && !KeyStuffed - ) { - /* Do save when IM is on, or IM is off and saved status is on. */ - if (vgetc_im_active) - *psave = B_IMODE_IM; - else if (*psave == B_IMODE_IM) - *psave = B_IMODE_NONE; - } -} -#endif - diff --git a/src/nvim/version.c b/src/nvim/version.c index c2818edcc5..f73e5c8cae 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -188,18 +188,18 @@ static int included_patches[] = { //481, //480, //479, - //478, + 478, //477, //476, //475, //474, - //473, - //472, + 473, + 472, //471, //470, //469, //468, - //467, + 467, //465, //464, //463, @@ -230,7 +230,7 @@ static int included_patches[] = { //438, 437, 436, - //435, + 435, //434, 433, //432 NA @@ -240,7 +240,7 @@ static int included_patches[] = { //428 NA 427, //426 NA - //425, + 425, //424 NA //423, //422, |