diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/README.md | 26 | ||||
-rw-r--r-- | src/nvim/diff.c | 91 | ||||
-rw-r--r-- | src/nvim/edit.c | 8 | ||||
-rw-r--r-- | src/nvim/eval.c | 31 | ||||
-rw-r--r-- | src/nvim/ex_cmds.c | 22 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 15 | ||||
-rw-r--r-- | src/nvim/ex_getln.c | 2 | ||||
-rw-r--r-- | src/nvim/fileio.c | 10 | ||||
-rw-r--r-- | src/nvim/fold.c | 6 | ||||
-rw-r--r-- | src/nvim/main.c | 42 | ||||
-rw-r--r-- | src/nvim/screen.c | 2 | ||||
-rw-r--r-- | src/nvim/search.c | 16 | ||||
-rw-r--r-- | src/nvim/syntax.c | 13 | ||||
-rw-r--r-- | src/nvim/testdir/Makefile | 2 | ||||
-rw-r--r-- | src/nvim/testdir/test13.in | 6 | ||||
-rw-r--r-- | src/nvim/testdir/test13.ok | 1 | ||||
-rw-r--r-- | src/nvim/testdir/test30.in | 58 | ||||
-rw-r--r-- | src/nvim/testdir/test30.ok | 9 | ||||
-rw-r--r-- | src/nvim/testdir/test45.in | 80 | ||||
-rw-r--r-- | src/nvim/testdir/test45.ok | 18 | ||||
-rw-r--r-- | src/nvim/testdir/test47.in | 45 | ||||
-rw-r--r-- | src/nvim/testdir/test47.ok | 40 | ||||
-rw-r--r-- | src/nvim/version.c | 28 |
23 files changed, 308 insertions, 263 deletions
diff --git a/src/nvim/README.md b/src/nvim/README.md index e4939d94fd..f16c6de12f 100644 --- a/src/nvim/README.md +++ b/src/nvim/README.md @@ -11,7 +11,7 @@ that are constantly changing. As the code becomes more organized and stable, this document will be updated to reflect the changes. If you are looking for module-specific details, it is best to read the source -code. Some files are extensively commented at the top(eg: terminal.c, +code. Some files are extensively commented at the top (e.g. terminal.c, screen.c). ### Top-level program loops @@ -43,13 +43,13 @@ a typical editing session: Note that we have split user actions into sequences of inputs that change the state of the editor. While there's no documentation about a "g command -mode"(step 16), internally it is implemented similarly to "operator-pending +mode" (step 16), internally it is implemented similarly to "operator-pending mode". From this we can see that Vim has the behavior of a input-driven state -machine(more specifically, a pushdown automaton since it requires a stack for +machine (more specifically, a pushdown automaton since it requires a stack for transitioning back from states). Assuming each state has a callback responsible -for handling keys, this pseudocode(a python-like language) shows a good +for handling keys, this pseudocode (a python-like language) shows a good representation of the main program loop: ```py @@ -129,20 +129,20 @@ def insert_state(data, key): While the actual code is much more complicated, the above gives an idea of how Neovim is organized internally. Some states like the `g_command_state` or `get_operator_count_state` do not have a dedicated `state_enter` callback, but -are implicitly embedded into other states(this will change later as we continue +are implicitly embedded into other states (this will change later as we continue the refactoring effort). To start reading the actual code, here's the recommended order: -1. `state_enter()` function(state.c). This is the actual program loop, +1. `state_enter()` function (state.c). This is the actual program loop, note that a `VimState` structure is used, which contains function pointers for the callback and state data. -2. `main()` function(main.c). After all startup, `normal_enter` is called +2. `main()` function (main.c). After all startup, `normal_enter` is called at the end of function to enter normal mode. -3. `normal_enter()` function(normal.c) is a small wrapper for setting +3. `normal_enter()` function (normal.c) is a small wrapper for setting up the NormalState structure and calling `state_enter`. -4. `normal_check()` function(normal.c) is called before each iteration of +4. `normal_check()` function (normal.c) is called before each iteration of normal mode. -5. `normal_execute()` function(normal.c) is called when a key is read in normal +5. `normal_execute()` function (normal.c) is called when a key is read in normal mode. The basic structure described for normal mode in 3, 4 and 5 is used for other @@ -159,7 +159,7 @@ asynchronous events, which can include: - msgpack-rpc requests - job control callbacks -- timers(not implemented yet but the support code is already there) +- timers (not implemented yet but the support code is already there) Neovim implements this functionality by entering another event loop while waiting for characters, so instead of: @@ -180,11 +180,11 @@ def state_enter(state_callback, data): while state_callback(data, event) # invoke the callback for the current state ``` -where `event` is something the operating system delivers to us, including(but +where `event` is something the operating system delivers to us, including (but not limited to) user input. The `read_next_event()` part is internally implemented by libuv, the platform layer used by Neovim. Since Neovim inherited its code from Vim, the states are not prepared to receive -"arbitrary events", so we use a special key to represent those(When a state +"arbitrary events", so we use a special key to represent those (When a state receives an "arbitrary event", it normally doesn't do anything other update the screen). diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 2776e45f5d..e06ffd0bbc 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -1057,27 +1057,28 @@ void diff_win_options(win_T *wp, int addbuf) newFoldLevel(); curwin = old_curwin; - wp->w_p_diff = TRUE; - // Use 'scrollbind' and 'cursorbind' when available - if (!wp->w_p_diff_saved) { + if (!wp->w_p_diff) { wp->w_p_scb_save = wp->w_p_scb; } wp->w_p_scb = TRUE; - if (!wp->w_p_diff_saved) { + if (!wp->w_p_diff) { wp->w_p_crb_save = wp->w_p_crb; } wp->w_p_crb = TRUE; - if (!wp->w_p_diff_saved) { + if (!wp->w_p_diff) { wp->w_p_wrap_save = wp->w_p_wrap; } wp->w_p_wrap = FALSE; curwin = wp; curbuf = curwin->w_buffer; - if (!wp->w_p_diff_saved) { + if (!wp->w_p_diff) { + if (wp->w_p_diff_saved) { + free_string_option(wp->w_p_fdm_save); + } wp->w_p_fdm_save = vim_strsave(wp->w_p_fdm); } set_string_option_direct((char_u *)"fdm", -1, (char_u *)"diff", @@ -1085,7 +1086,7 @@ void diff_win_options(win_T *wp, int addbuf) curwin = old_curwin; curbuf = curwin->w_buffer; - if (!wp->w_p_diff_saved) { + if (!wp->w_p_diff) { wp->w_p_fdc_save = wp->w_p_fdc; wp->w_p_fen_save = wp->w_p_fen; wp->w_p_fdl_save = wp->w_p_fdl; @@ -1104,6 +1105,8 @@ void diff_win_options(win_T *wp, int addbuf) // Saved the current values, to be restored in ex_diffoff(). wp->w_p_diff_saved = TRUE; + wp->w_p_diff = true; + if (addbuf) { diff_buf_add(wp->w_buffer); } @@ -1116,68 +1119,50 @@ void diff_win_options(win_T *wp, int addbuf) /// @param eap void ex_diffoff(exarg_T *eap) { - win_T *old_curwin = curwin; - int diffwin = FALSE; + int diffwin = false; FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { if (eap->forceit ? wp->w_p_diff : (wp == curwin)) { - // Set 'diff', 'scrollbind' off and 'wrap' on. If option values - // were saved in diff_win_options() restore them. - wp->w_p_diff = FALSE; - - if (wp->w_p_scb) { - wp->w_p_scb = wp->w_p_diff_saved ? wp->w_p_scb_save : FALSE; - } - - if (wp->w_p_crb) { - wp->w_p_crb = wp->w_p_diff_saved ? wp->w_p_crb_save : FALSE; - } - - if (!wp->w_p_wrap) { - wp->w_p_wrap = wp->w_p_diff_saved ? wp->w_p_wrap_save : TRUE; - } - curwin = wp; - curbuf = curwin->w_buffer; + // Set 'diff' off. If option values were saved in + // diff_win_options(), restore the ones whose settings seem to have + // been left over from diff mode. + wp->w_p_diff = false; if (wp->w_p_diff_saved) { - free_string_option(wp->w_p_fdm); - wp->w_p_fdm = wp->w_p_fdm_save; - wp->w_p_fdm_save = empty_option; - } else { - set_string_option_direct((char_u *)"fdm", -1, - (char_u *)"manual", OPT_LOCAL | OPT_FREE, 0); - } - curwin = old_curwin; - curbuf = curwin->w_buffer; + if (wp->w_p_scb) { + wp->w_p_scb = wp->w_p_scb_save; + } - if (wp->w_p_fdc == diff_foldcolumn) { - wp->w_p_fdc = wp->w_p_diff_saved ? wp->w_p_fdc_save : 0; - } + if (wp->w_p_crb) { + wp->w_p_crb = wp->w_p_crb_save; + } - if ((wp->w_p_fdl == 0) - && wp->w_p_diff_saved) { - wp->w_p_fdl = wp->w_p_fdl_save; - } + if (!wp->w_p_wrap) { + wp->w_p_wrap = wp->w_p_wrap_save; + } - if (wp->w_p_fen) { + free_string_option(wp->w_p_fdm); + wp->w_p_fdm = vim_strsave(wp->w_p_fdm_save); + if (wp->w_p_fdc == diff_foldcolumn) { + wp->w_p_fdc = wp->w_p_fdc_save; + } + if (wp->w_p_fdl == 0) { + wp->w_p_fdl = wp->w_p_fdl_save; + } // Only restore 'foldenable' when 'foldmethod' is not // "manual", otherwise we continue to show the diff folds. - if (foldmethodIsManual(wp) || !wp->w_p_diff_saved) { - wp->w_p_fen = FALSE; - } else { - wp->w_p_fen = wp->w_p_fen_save; + if (wp->w_p_fen) { + wp->w_p_fen = foldmethodIsManual(wp) ? false : wp->w_p_fen_save; } - } - foldUpdateAll(wp); + foldUpdateAll(wp); - // make sure topline is not halfway through a fold - changed_window_setting_win(wp); + // make sure topline is not halfway through a fold + changed_window_setting_win(wp); + } // Note: 'sbo' is not restored, it's a global option. diff_buf_adjust(wp); - - wp->w_p_diff_saved = FALSE; } diffwin |= wp->w_p_diff; } diff --git a/src/nvim/edit.c b/src/nvim/edit.c index dbbcf4f1b9..213df4f65a 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -2548,8 +2548,12 @@ void ins_compl_show_pum(void) } } - /* Compute the screen column of the start of the completed text. - * Use the cursor to get all wrapping and other settings right. */ + // In Replace mode when a $ is displayed at the end of the line only + // part of the screen would be updated. We do need to redraw here. + dollar_vcol = -1; + + // Compute the screen column of the start of the completed text. + // Use the cursor to get all wrapping and other settings right. col = curwin->w_cursor.col; curwin->w_cursor.col = compl_col; pum_display(compl_match_array, compl_match_arraysize, cur); diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 0d7e2f7b5d..8971b6d463 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -3045,12 +3045,13 @@ static int do_lock_var(lval_T *lp, char_u *name_end, int deep, int lock) li = li->li_next; ++lp->ll_n1; } - } else if (lp->ll_list != NULL) - /* (un)lock a List item. */ + } else if (lp->ll_list != NULL) { + // (un)lock a List item. item_lock(&lp->ll_li->li_tv, deep, lock); - else - /* un(lock) a Dictionary item. */ + } else { + // (un)lock a Dictionary item. item_lock(&lp->ll_di->di_tv, deep, lock); + } return ret; } @@ -7337,7 +7338,7 @@ static struct fst { { "sqrt", 1, 1, f_sqrt }, { "str2float", 1, 1, f_str2float }, { "str2nr", 1, 2, f_str2nr }, - { "strchars", 1, 1, f_strchars }, + { "strchars", 1, 2, f_strchars }, { "strdisplaywidth", 1, 2, f_strdisplaywidth }, { "strftime", 1, 2, f_strftime }, { "stridx", 2, 3, f_stridx }, @@ -10988,8 +10989,6 @@ static void f_has(typval_T *argvars, typval_T *rettv) #endif } else if (STRICMP(name, "syntax_items") == 0) { n = syntax_present(curwin); - } else if (STRICMP(name, "gui_running") == 0) { - n = ui_rgb_attached(); } } @@ -16215,13 +16214,23 @@ static void f_strlen(typval_T *argvars, typval_T *rettv) static void f_strchars(typval_T *argvars, typval_T *rettv) { char_u *s = get_tv_string(&argvars[0]); + int skipcc = 0; varnumber_T len = 0; + int (*func_mb_ptr2char_adv)(char_u **pp); - while (*s != NUL) { - mb_cptr2char_adv(&s); - ++len; + if (argvars[1].v_type != VAR_UNKNOWN) { + skipcc = get_tv_number_chk(&argvars[1], NULL); + } + if (skipcc < 0 || skipcc > 1) { + EMSG(_(e_invarg)); + } else { + func_mb_ptr2char_adv = skipcc ? mb_ptr2char_adv : mb_cptr2char_adv; + while (*s != NUL) { + func_mb_ptr2char_adv(&s); + ++len; + } + rettv->vval.v_number = len; } - rettv->vval.v_number = len; } /* diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index a517037431..4d62dd0ff9 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -690,9 +690,17 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest) { char_u *str; linenr_T l; - linenr_T extra; /* Num lines added before line1 */ - linenr_T num_lines; /* Num lines moved */ - linenr_T last_line; /* Last line in file after adding new text */ + linenr_T extra; // Num lines added before line1 + linenr_T num_lines; // Num lines moved + linenr_T last_line; // Last line in file after adding new text + + // Moving lines seems to corrupt the folds, delete folding info now + // and recreate it when finished. Don't do this for manual folding, it + // would delete all folds. + bool isFolded = hasAnyFolding(curwin) && !foldmethodIsManual(curwin); + if (isFolded) { + deleteFoldRecurse(&curwin->w_folds); + } if (dest >= line1 && dest < line2) { EMSG(_("E134: Move lines into themselves")); @@ -777,8 +785,14 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest) if (dest > last_line + 1) dest = last_line + 1; changed_lines(line1, 0, dest, 0L); - } else + } else { changed_lines(dest + 1, 0, line1 + num_lines, 0L); + } + + // recreate folds + if (isFolded) { + foldUpdateAll(curwin); + } return OK; } diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index c45be3de74..50513c0a6a 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -5659,8 +5659,13 @@ static void ex_quit(exarg_T *eap) || (only_one_window() && check_changed_any(eap->forceit))) { not_exiting(); } else { - if (only_one_window()) { - // quit last window + // quit last window + // Note: only_one_window() returns true, even so a help window is + // still open. In that case only quit, if no address has been + // specified. Example: + // :h|wincmd w|1q - don't quit + // :h|wincmd w|q - quit + if (only_one_window() && (firstwin == lastwin || eap->addr_count == 0)) { getout(0); } /* close window; may free buffer */ @@ -8366,8 +8371,7 @@ makeopens ( { int only_save_windows = TRUE; int nr; - int cnr = 1; - int restore_size = TRUE; + int restore_size = true; win_T *wp; char_u *sname; win_T *edited_win = NULL; @@ -8484,7 +8488,8 @@ makeopens ( tab_firstwin = firstwin; /* first window in tab page "tabnr" */ tab_topframe = topframe; for (tabnr = 1;; ++tabnr) { - int need_tabnew = FALSE; + int need_tabnew = false; + int cnr = 1; if ((ssop_flags & SSOP_TABPAGES)) { tabpage_T *tp = find_tabpage(tabnr); diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 96bf2c78d2..d015f6b4a0 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -5136,6 +5136,8 @@ static int ex_window(void) /* Don't execute autocommands while deleting the window. */ block_autocmds(); + // Avoid command-line window first character being concealed + curwin->w_p_cole = 0; wp = curwin; bp = curbuf; win_goto(old_curwin); diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 8fe7ad0e30..383cd47dbe 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -1543,12 +1543,12 @@ rewind_retry: if (fileformat == EOL_UNKNOWN) { /* First try finding a NL, for Dos and Unix */ if (try_dos || try_unix) { - for (p = ptr; p < ptr + size; ++p) { - // Reset the carriage return counter. - if (try_mac) { - try_mac = 1; - } + // Reset the carriage return counter. + if (try_mac) { + try_mac = 1; + } + for (p = ptr; p < ptr + size; ++p) { if (*p == NL) { if (!try_unix || (try_dos && p > ptr && p[-1] == CAR)) diff --git a/src/nvim/fold.c b/src/nvim/fold.c index 2e32e78062..6c135ef47b 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -767,9 +767,9 @@ void foldUpdate(win_T *wp, linenr_T top, linenr_T bot) return; } - /* Mark all folds from top to bot as maybe-small. */ - (void)foldFind(&curwin->w_folds, top, &fp); - while (fp < (fold_T *)curwin->w_folds.ga_data + curwin->w_folds.ga_len + // Mark all folds from top to bot as maybe-small. + (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; diff --git a/src/nvim/main.c b/src/nvim/main.c index cef10d12d5..a8c2cebbbd 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -219,9 +219,10 @@ int main(int argc, char **argv) { argv0 = (char *)path_tail((char_u *)argv[0]); - char_u *fname = NULL; /* file name from command line */ - mparm_T params; /* various parameters passed between - * main() and other functions. */ + char_u *fname = NULL; // file name from command line + mparm_T params; // various parameters passed between + // main() and other functions. + char_u *cwd = NULL; // current workding dir on startup time_init(); /* Many variables are in "params" so that we can pass them to invoked @@ -461,11 +462,10 @@ int main(int argc, char **argv) TIME_MSG("jump to first error"); } - /* - * If opened more than one window, start editing files in the other - * windows. - */ - edit_buffers(¶ms); + // If opened more than one window, start editing files in the other + // windows. + edit_buffers(¶ms, cwd); + xfree(cwd); if (params.diff_mode) { /* set options in each window for "nvim -d". */ @@ -1182,12 +1182,19 @@ static char_u *get_fname(mparm_T *parmp) * Expand wildcards in file names. */ if (!parmp->literal) { - /* Temporarily add '(' and ')' to 'isfname'. These are valid - * filename characters but are excluded from 'isfname' to make - * "gf" work on a file name in parenthesis (e.g.: see vim.h). */ + cwd = xmalloc(MAXPATHL); + if (cwd != NULL) { + os_dirname(cwd, MAXPATHL); + } + // Temporarily add '(' and ')' to 'isfname'. These are valid + // filename characters but are excluded from 'isfname' to make + // "gf" work on a file name in parenthesis (e.g.: see vim.h). do_cmdline_cmd(":set isf+=(,)"); alist_expand(NULL, 0); do_cmdline_cmd(":set isf&"); + if (cwd != NULL) { + os_chdir((char *)cwd); + } } #endif return alist_name(&GARGLIST[0]); @@ -1417,11 +1424,9 @@ static void create_windows(mparm_T *parmp) } } -/* - * If opened more than one window, start editing files in the other - * windows. make_windows() has already opened the windows. - */ -static void edit_buffers(mparm_T *parmp) +/// If opened more than one window, start editing files in the other +/// windows. make_windows() has already opened the windows. +static void edit_buffers(mparm_T *parmp, char_u *cwd) { int arg_idx; /* index in argument list */ int i; @@ -1442,7 +1447,10 @@ static void edit_buffers(mparm_T *parmp) arg_idx = 1; for (i = 1; i < parmp->window_count; ++i) { - /* When w_arg_idx is -1 remove the window (see create_windows()). */ + if (cwd != NULL) { + os_chdir((char *)cwd); + } + // When w_arg_idx is -1 remove the window (see create_windows()). if (curwin->w_arg_idx == -1) { ++arg_idx; win_close(curwin, TRUE); diff --git a/src/nvim/screen.c b/src/nvim/screen.c index be8307e8b3..e036c49be4 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -6222,8 +6222,8 @@ void clear_tab_page_click_defs(StlClickDefinition *const tpcd, xfree(tpcd[i].func); } } + memset(tpcd, 0, (size_t) tpcd_size * sizeof(tpcd[0])); } - memset(tpcd, 0, (size_t) tpcd_size * sizeof(tpcd[0])); } void screenclear(void) diff --git a/src/nvim/search.c b/src/nvim/search.c index d393ee7d02..2dd0201259 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -3076,18 +3076,18 @@ current_block ( } else old_end = VIsual; - /* - * Search backwards for unclosed '(', '{', etc.. - * Put this position in start_pos. - * Ignore quotes here. - */ + // Search backwards for unclosed '(', '{', etc.. + // Put this position in start_pos. + // Ignore quotes here. Keep the "M" flag in 'cpo', as that is what the + // user wants. save_cpo = p_cpo; - p_cpo = (char_u *)"%"; + p_cpo = (char_u *)(vim_strchr(p_cpo, CPO_MATCHBSL) != NULL ? "%M" : "%"); while (count-- > 0) { - if ((pos = findmatch(NULL, what)) == NULL) + if ((pos = findmatch(NULL, what)) == NULL) { break; + } curwin->w_cursor = *pos; - start_pos = *pos; /* the findmatch for end_pos will overwrite *pos */ + start_pos = *pos; // the findmatch for end_pos will overwrite *pos } p_cpo = save_cpo; diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index f47c5eadd3..494683d254 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -3004,14 +3004,19 @@ static void syn_cmd_spell(exarg_T *eap, int syncing) return; next = skiptowhite(arg); - if (STRNICMP(arg, "toplevel", 8) == 0 && next - arg == 8) + if (STRNICMP(arg, "toplevel", 8) == 0 && next - arg == 8) { curwin->w_s->b_syn_spell = SYNSPL_TOP; - else if (STRNICMP(arg, "notoplevel", 10) == 0 && next - arg == 10) + } else if (STRNICMP(arg, "notoplevel", 10) == 0 && next - arg == 10) { curwin->w_s->b_syn_spell = SYNSPL_NOTOP; - else if (STRNICMP(arg, "default", 7) == 0 && next - arg == 7) + } else if (STRNICMP(arg, "default", 7) == 0 && next - arg == 7) { curwin->w_s->b_syn_spell = SYNSPL_DEFAULT; - else + } else { EMSG2(_("E390: Illegal argument: %s"), arg); + return; + } + + // assume spell checking changed, force a redraw + redraw_win_later(curwin, NOT_VALID); } /* diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index fe511166f2..d1a7abfbf7 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -15,7 +15,7 @@ SCRIPTS := \ test30.out \ test32.out test34.out \ test36.out test37.out test40.out \ - test42.out test45.out \ + test42.out \ test47.out test48.out test49.out \ test52.out test53.out test55.out \ test64.out \ diff --git a/src/nvim/testdir/test13.in b/src/nvim/testdir/test13.in index cb8a6fff89..6713f80e88 100644 --- a/src/nvim/testdir/test13.in +++ b/src/nvim/testdir/test13.in @@ -48,6 +48,12 @@ otestje3 :au BufWipeout Xtestje1 buf Xtestje1 :bwipe :w >>test.out +:only +:new|set buftype=help +:wincmd w +:1quit +:$put ='Final line' +:$w >>test.out :qa! ENDTEST diff --git a/src/nvim/testdir/test13.ok b/src/nvim/testdir/test13.ok index 0f1fc347a4..66ebce63f7 100644 --- a/src/nvim/testdir/test13.ok +++ b/src/nvim/testdir/test13.ok @@ -28,3 +28,4 @@ testje1 contents contents end of testfile +Final line diff --git a/src/nvim/testdir/test30.in b/src/nvim/testdir/test30.in index 3f7b9eb472..2a89eac73d 100644 --- a/src/nvim/testdir/test30.in +++ b/src/nvim/testdir/test30.in @@ -7,32 +7,27 @@ STARTTEST :" first write three test files, one in each format :set fileformat=unix :set fileformats= -:/^1/w! XX1 -:/^2/w! XX2 -:/^3/w! XX3 -:/^4/w! XX4 -:/^5/w! XX5 -:/^6/w! XX6 -:/^7/w! XX7 -:/^8/w! XX8 -:/^9/w! XX9 -:/^10/w! XX10 :/^unix/;/eof/-1w! XXUnix :/^dos/;/eof/-1w! XXDos :set bin noeol :$w! XXMac +Gonoeol +:$w! XXEol :set nobin eol +:enew! :bwipe XXUnix XXDos XXMac :" create mixed format files :if has("win32") : !copy /b XXUnix+XXDos XXUxDs : !copy /b XXUnix+XXMac XXUxMac : !copy /b XXDos+XXMac XXDosMac +: !copy /b XXMac+XXEol XXMacEol : !copy /b XXUnix+XXDos+XXMac XXUxDsMc :else : !cat XXUnix XXDos >XXUxDs : !cat XXUnix XXMac >XXUxMac : !cat XXDos XXMac >XXDosMac +: !cat XXMac XXEol >XXMacEol : !cat XXUnix XXDos XXMac >XXUxDsMc :endif :" @@ -97,26 +92,48 @@ STARTTEST :e! XXDosMac :w! XXtt53 :bwipe XXDosMac +:e! XXEol +ggO=&ffs +:=&ff +:w! XXtt54 +:bwipe XXEol :set fileformats=dos,mac :e! XXUxDs :w! XXtt61 :bwipe XXUxDs :e! XXUxMac -:w! XXtt62 +ggO=&ffs +:=&ff +:w! XXtt62 :bwipe XXUxMac :e! XXUxDsMc :w! XXtt63 :bwipe XXUxDsMc +:e! XXMacEol +ggO=&ffs +:=&ff +:w! XXtt64 +:bwipe XXMacEol :" :" try reading and writing with 'fileformats' set to three formats :set fileformats=unix,dos,mac :e! XXUxDsMc :w! XXtt71 :bwipe XXUxDsMc +:e! XXEol +ggO=&ffs +:=&ff +:w! XXtt72 +:bwipe XXEol :set fileformats=mac,dos,unix :e! XXUxDsMc :w! XXtt81 :bwipe XXUxDsMc +:e! XXEol +ggO=&ffs +:=&ff +:w! XXtt82 +:bwipe XXEol :" try with 'binary' set :set fileformats=mac,unix,dos :set binary @@ -150,11 +167,15 @@ ggdGaEND:w >>XXtt01 :w >>XXtt51 :w >>XXtt52 :w >>XXtt53 +:w >>XXtt54 :w >>XXtt61 :w >>XXtt62 :w >>XXtt63 +:w >>XXtt64 :w >>XXtt71 +:w >>XXtt72 :w >>XXtt81 +:w >>XXtt82 :w >>XXtt91 :w >>XXtt92 :w >>XXtt93 @@ -181,11 +202,15 @@ Go4:$r XXtt41 Go5:$r XXtt51 :$r XXtt52 :$r XXtt53 +:$r XXtt54 Go6:$r XXtt61 :$r XXtt62 :$r XXtt63 +:$r XXtt64 Go7:$r XXtt71 +:$r XXtt72 Go8:$r XXtt81 +:$r XXtt82 Go9:$r XXtt91 :$r XXtt92 :$r XXtt93 @@ -195,17 +220,6 @@ Go10:$r XXUnix :qa! ENDTEST -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 - unix unix eof diff --git a/src/nvim/testdir/test30.ok b/src/nvim/testdir/test30.ok index 380ce67061..b35f4f5904 100644 --- a/src/nvim/testdir/test30.ok +++ b/src/nvim/testdir/test30.ok @@ -70,12 +70,16 @@ END dos
dos
mac
mac
END +unix,mac:unix +noeol +END 6 unix
unix
dos
dos
END +dos,mac:dos
unix
unix
mac
mac
@@ -86,6 +90,7 @@ dos dos
mac
mac
END +dos,mac:mac
mac
mac
noeol
END 7 unix unix @@ -93,6 +98,9 @@ dos dos
mac
mac
END +unix,dos,mac:unix +noeol +END 8 unix unix @@ -100,6 +108,7 @@ dos dos
mac
mac
END +mac,dos,unix:mac
noeol
END 9 unix unix diff --git a/src/nvim/testdir/test45.in b/src/nvim/testdir/test45.in deleted file mode 100644 index e5af5073d9..0000000000 --- a/src/nvim/testdir/test45.in +++ /dev/null @@ -1,80 +0,0 @@ -Tests for folding. vim: set ft=vim : - -STARTTEST -:so small.vim -:" We also need the +syntax feature here. -:if !has("syntax") - e! test.ok - w! test.out - qa! -:endif -:" basic test if a fold can be created, opened, moving to the end and closed -/^1 -zf2j:call append("$", "manual " . getline(foldclosed("."))) -zo:call append("$", foldclosed(".")) -]z:call append("$", getline(".")) -zc:call append("$", getline(foldclosed("."))) -:" test folding with markers. -:set fdm=marker fdl=1 fdc=3 -/^5 -:call append("$", "marker " . foldlevel(".")) -[z:call append("$", foldlevel(".")) -jo{{ r{jj:call append("$", foldlevel(".")) -kYpj:call append("$", foldlevel(".")) -:" test folding with indent -:set fdm=indent sw=2 -/^2 b -i jI :call append("$", "indent " . foldlevel(".")) -k:call append("$", foldlevel(".")) -:" test syntax folding -:set fdm=syntax fdl=0 -:syn region Hup start="dd" end="ii" fold contains=Fd1,Fd2,Fd3 -:syn region Fd1 start="ee" end="ff" fold contained -:syn region Fd2 start="gg" end="hh" fold contained -:syn region Fd3 start="commentstart" end="commentend" fold contained -Gzk:call append("$", "folding " . getline(".")) -k:call append("$", getline(".")) -jAcommentstart Acommentend:set fdl=1 -3j:call append("$", getline(".")) -:set fdl=0 -zOj:call append("$", getline(".")) -:" test expression folding -:fun Flvl() - let l = getline(v:lnum) - if l =~ "bb$" - return 2 - elseif l =~ "gg$" - return "s1" - elseif l =~ "ii$" - return ">2" - elseif l =~ "kk$" - return "0" - endif - return "=" -endfun -:set fdm=expr fde=Flvl() -/bb$ -:call append("$", "expr " . foldlevel(".")) -/hh$ -:call append("$", foldlevel(".")) -/ii$ -:call append("$", foldlevel(".")) -/kk$ -:call append("$", foldlevel(".")) -:/^last/+1,$w! test.out -:delfun Flvl -:qa! -ENDTEST - -1 aa -2 bb -3 cc -4 dd {{{ -5 ee {{{ }}} -6 ff }}} -7 gg -8 hh -9 ii -a jj -b kk -last diff --git a/src/nvim/testdir/test45.ok b/src/nvim/testdir/test45.ok deleted file mode 100644 index f04996e337..0000000000 --- a/src/nvim/testdir/test45.ok +++ /dev/null @@ -1,18 +0,0 @@ -manual 1 aa --1 -3 cc -1 aa -marker 2 -1 -1 -0 -indent 2 -1 -folding 9 ii - 3 cc -7 gg -8 hh -expr 2 -1 -2 -0 diff --git a/src/nvim/testdir/test47.in b/src/nvim/testdir/test47.in index 13ad82462f..f15eaf0f8f 100644 --- a/src/nvim/testdir/test47.in +++ b/src/nvim/testdir/test47.in @@ -1,5 +1,7 @@ Tests for vertical splits and filler lines in diff mode +Also tests restoration of saved options by :diffoff. + STARTTEST :so small.vim :" Disable the title to avoid xterm keeping the wrong one. @@ -10,8 +12,19 @@ pkdd:w! Xtest ddGpkkrXoxxx:w! Xtest2 :file Nop ggoyyyjjjozzzz +:set foldmethod=marker foldcolumn=4 +:redir => nodiffsettings +:silent! :set diff? fdm? fdc? scb? crb? wrap? +:redir END :vert diffsplit Xtest :vert diffsplit Xtest2 +:redir => diffsettings +:silent! :set diff? fdm? fdc? scb? crb? wrap? +:redir END +:let diff_fdm = &fdm +:let diff_fdc = &fdc +:" repeat entering diff mode here to see if this saves the wrong settings +:diffthis :" jump to second window for a moment to have filler line appear at start of :" first window ggpgg:let one = winline() @@ -36,8 +49,36 @@ j:let three = three . "-" . winline() :call append("$", two) :call append("$", three) :$-2,$w! test.out -:" Test that diffing shows correct filler lines +:" +:" Test diffoff :diffoff! +1 +:let &diff = 1 +:let &fdm = diff_fdm +:let &fdc = diff_fdc +4 +:diffoff! +:$put =nodiffsettings +:$put =diffsettings +1 +:redir => nd1 +:silent! :set diff? fdm? fdc? scb? crb? wrap? +:redir END + +:redir => nd2 +:silent! :set diff? fdm? fdc? scb? crb? wrap? +:redir END + +:redir => nd3 +:silent! :set diff? fdm? fdc? scb? crb? wrap? +:redir END + +:$put =nd1 +:$put =nd2 +:$put =nd3 +:$-39,$w >> test.out +:" +:" Test that diffing shows correct filler lines :windo :bw! :enew :put =range(4,10) @@ -51,7 +92,7 @@ j:let three = three . "-" . winline() :enew :put =w0 :.w >> test.out -:unlet! one two three w0 +:unlet! one two three nodiffsettings diffsettings diff_fdm diff_fdc nd1 nd2 nd3 w0 :qa! ENDTEST diff --git a/src/nvim/testdir/test47.ok b/src/nvim/testdir/test47.ok index b1cba92b1c..83e96571ad 100644 --- a/src/nvim/testdir/test47.ok +++ b/src/nvim/testdir/test47.ok @@ -1,4 +1,44 @@ 2-4-5-6-8-9 1-2-4-5-8 2-3-4-5-6-7-8 + + +nodiff + foldmethod=marker + foldcolumn=4 +noscrollbind +nocursorbind + wrap + + + diff + foldmethod=diff + foldcolumn=2 + scrollbind + cursorbind +nowrap + + +nodiff + foldmethod=marker + foldcolumn=4 +noscrollbind +nocursorbind + wrap + + +nodiff + foldmethod=marker + foldcolumn=4 +noscrollbind +nocursorbind + wrap + + +nodiff + foldmethod=marker + foldcolumn=4 +noscrollbind +nocursorbind + wrap 1 diff --git a/src/nvim/version.c b/src/nvim/version.c index 2225611779..3fb1738f2a 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -487,7 +487,7 @@ static int included_patches[] = { // 804, 803, 802, - // 801, + 801, 800, 799, 798, @@ -519,8 +519,8 @@ static int included_patches[] = { // 772 NA // 771, // 770 NA - // 769, - // 768, + 769, + 768, // 767, // 766 NA 765, @@ -528,12 +528,12 @@ static int included_patches[] = { // 763 NA // 762 NA // 761 NA - // 760, + 760, // 759 NA - // 758, + 758, // 757 NA // 756 NA - // 755, + 755, 754, 753, // 752, @@ -548,7 +548,7 @@ static int included_patches[] = { // 743, // 742, 741, - // 740, + 740, 739, // 738 NA // 737, @@ -588,19 +588,19 @@ static int included_patches[] = { // 703 NA 702, // 701 NA - // 700, + 700, 699, 698, 697, 696, 695, - // 694, - // 693, + 694, + 693, // 692 NA // 691 NA 690, - // 689, - // 688, + 689, + 688, // 687 NA 686, 685, @@ -626,7 +626,7 @@ static int included_patches[] = { 665, // 664 NA // 663 NA - // 662, + 662, // 661 NA 660, 659, @@ -645,7 +645,7 @@ static int included_patches[] = { 646, 645, // 644 NA - // 643, + 643, 642, // 641 NA 640, |