diff options
-rw-r--r-- | runtime/doc/options.txt | 56 | ||||
-rw-r--r-- | src/nvim/ex_cmds.c | 6 | ||||
-rw-r--r-- | src/nvim/fold.c | 8 | ||||
-rw-r--r-- | src/nvim/testdir/test_fold.vim | 20 | ||||
-rw-r--r-- | test/functional/legacy/prompt_buffer_spec.lua | 19 | ||||
-rw-r--r-- | test/functional/ui/bufhl_spec.lua | 10 | ||||
-rw-r--r-- | test/functional/ui/fold_spec.lua | 61 | ||||
-rw-r--r-- | test/functional/ui/messages_spec.lua | 6 | ||||
-rw-r--r-- | test/functional/ui/searchhl_spec.lua | 44 | ||||
-rw-r--r-- | test/functional/vimscript/execute_spec.lua | 4 |
10 files changed, 176 insertions, 58 deletions
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index cc035a9f74..0c2de7d6ee 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -776,7 +776,7 @@ A jump table for the options with a short description can be found at |Q_op|. oldest version of a file. *'backupcopy'* *'bkc'* -'backupcopy' 'bkc' string (Vi default for Unix: "yes", otherwise: "auto") +'backupcopy' 'bkc' string (default: "auto") global or local to buffer |global-local| When writing a file and a backup is made, this option tells how it's done. This is a comma-separated list of words. @@ -1192,7 +1192,7 @@ A jump table for the options with a short description can be found at |Q_op|. (parts of 'cdpath' can be passed to the shell to expand file names). *'cedit'* -'cedit' string (Vim default: CTRL-F, Vi default: "") +'cedit' string (default: CTRL-F) global The key used in Command-line Mode to open the command-line window. Only non-printable keys are allowed. @@ -1543,8 +1543,7 @@ A jump table for the options with a short description can be found at |Q_op|. See 'preserveindent'. *'cpoptions'* *'cpo'* *cpo* -'cpoptions' 'cpo' string (Vim default: "aABceFs_", - Vi default: all flags) +'cpoptions' 'cpo' string (default: "aABceFs_") global A sequence of single character flags. When a character is present this indicates Vi-compatible behavior. This is used for things where @@ -2113,7 +2112,7 @@ A jump table for the options with a short description can be found at |Q_op|. security reasons. *'display'* *'dy'* -'display' 'dy' string (default "lastline,msgsep", Vi default: "") +'display' 'dy' string (default "lastline,msgsep") global Change the way text is displayed. This is comma-separated list of flags: @@ -2359,9 +2358,8 @@ A jump table for the options with a short description can be found at |Q_op|. *'fileformats'* *'ffs'* 'fileformats' 'ffs' string (default: - Vim+Vi Win32: "dos,unix", - Vim Unix: "unix,dos", - Vi others: "") + Win32: "dos,unix", + Unix: "unix,dos") global This gives the end-of-line (<EOL>) formats that will be tried when starting to edit a new buffer and when reading a file into an existing @@ -2719,7 +2717,7 @@ A jump table for the options with a short description can be found at |Q_op|. character and white space. *'formatoptions'* *'fo'* -'formatoptions' 'fo' string (default: "tcqj", Vi default: "vt") +'formatoptions' 'fo' string (default: "tcqj") local to buffer This is a sequence of letters which describes how automatic formatting is to be done. See |fo-table|. When the 'paste' option is @@ -3151,7 +3149,7 @@ A jump table for the options with a short description can be found at |Q_op|. 'hidden' is set for one command with ":hide {command}" |:hide|. *'history'* *'hi'* -'history' 'hi' number (Vim default: 10000, Vi default: 0) +'history' 'hi' number (default: 10000) global A history of ":" commands, and a history of previous search patterns is remembered. This option decides how many entries may be stored in @@ -3506,8 +3504,7 @@ A jump table for the options with a short description can be found at |Q_op|. change 'iskeyword' instead. *'iskeyword'* *'isk'* -'iskeyword' 'isk' string (default: @,48-57,_,192-255 - Vi default: @,48-57,_) +'iskeyword' 'isk' string (default: @,48-57,_,192-255) local to buffer Keywords are used in searching and recognizing with many commands: "w", "*", "[i", etc. It is also used for "\k" in a |pattern|. See @@ -3777,8 +3774,7 @@ A jump table for the options with a short description can be found at |Q_op|. changing the way tabs are displayed. *'listchars'* *'lcs'* -'listchars' 'lcs' string (default: "tab:> ,trail:-,nbsp:+" - Vi default: "eol:$") +'listchars' 'lcs' string (default: "tab:> ,trail:-,nbsp:+") global or local to window |global-local| Strings to use in 'list' mode and for the |:list| command. It is a comma-separated list of string settings. @@ -4046,8 +4042,7 @@ A jump table for the options with a short description can be found at |Q_op|. This option cannot be set from a |modeline| or in the |sandbox|. *'modeline'* *'ml'* *'nomodeline'* *'noml'* -'modeline' 'ml' boolean (Vim default: on (off for root), - Vi default: off) +'modeline' 'ml' boolean (default: on (off for root)) local to buffer If 'modeline' is on 'modelines' gives the number of lines that is checked for set commands. If 'modeline' is off or 'modelines' is zero @@ -4102,7 +4097,7 @@ A jump table for the options with a short description can be found at |Q_op|. when using "rA" on an "A". *'more'* *'nomore'* -'more' boolean (Vim default: on, Vi default: off) +'more' boolean (default: on) global When on, listings pause when the whole screen is filled. You will get the |more-prompt|. When this option is off there are no pauses, the @@ -4357,7 +4352,7 @@ A jump table for the options with a short description can be found at |Q_op|. |there | 4 there | 1 there | 1 there *'numberwidth'* *'nuw'* -'numberwidth' 'nuw' number (Vim default: 4 Vi default: 8) +'numberwidth' 'nuw' number (default: 4) local to window Minimal number of columns to use for the line number. Only relevant when the 'number' or 'relativenumber' option is set or printing lines @@ -5113,9 +5108,7 @@ A jump table for the options with a short description can be found at |Q_op|. *'sessionoptions'* *'ssop'* 'sessionoptions' 'ssop' string (default: "blank,buffers,curdir,folds, - help,tabpages,winsize" - Vi default: "blank,buffers,curdir,folds, - help,options,tabpages,winsize") + help,tabpages,winsize") global Changes the effect of the |:mksession| command. It is a comma- separated list of words. Each word enables saving and restoring @@ -5155,10 +5148,9 @@ A jump table for the options with a short description can be found at |Q_op|. If you leave out "options" many things won't work well after restoring the session. *'shada'* *'sd'* *E526* *E527* *E528* -'shada' 'sd' string (Vim default for +'shada' 'sd' string (default for Win32: !,'100,<50,s10,h,rA:,rB: - others: !,'100,<50,s10,h - Vi default: "") + others: !,'100,<50,s10,h) global When non-empty, the shada file is read upon startup and written when exiting Vim (see |shada-file|). The string should be a comma- @@ -5436,7 +5428,7 @@ A jump table for the options with a short description can be found at |Q_op|. < Also see 'completeslash'. *'shelltemp'* *'stmp'* *'noshelltemp'* *'nostmp'* -'shelltemp' 'stmp' boolean (Vim default on, Vi default off) +'shelltemp' 'stmp' boolean (default on) global When on, use temp files for shell commands. When off use a pipe. When using a pipe is not possible temp files are used anyway. @@ -5485,7 +5477,7 @@ A jump table for the options with a short description can be found at |Q_op|. function to get the effective shiftwidth value. *'shortmess'* *'shm'* -'shortmess' 'shm' string (Vim default "filnxtToOF", Vi default: "S") +'shortmess' 'shm' string (default "filnxtToOF") global This option helps to avoid all the |hit-enter| prompts caused by file messages, for example with CTRL-G, and to avoid some other messages. @@ -5559,7 +5551,7 @@ A jump table for the options with a short description can be found at |Q_op|. :setlocal showbreak=NONE < *'showcmd'* *'sc'* *'noshowcmd'* *'nosc'* -'showcmd' 'sc' boolean (Vim default: on, Vi default: off) +'showcmd' 'sc' boolean (default: on) global Show (partial) command in the last line of the screen. Set this option off if your terminal is slow. @@ -5605,7 +5597,7 @@ A jump table for the options with a short description can be found at |Q_op|. Note: Use of the short form is rated PG. *'showmode'* *'smd'* *'noshowmode'* *'nosmd'* -'showmode' 'smd' boolean (Vim default: on, Vi default: off) +'showmode' 'smd' boolean (default: on) global If in Insert, Replace or Visual mode put a message on the last line. The |hl-ModeMsg| highlight group determines the highlighting. @@ -6389,7 +6381,7 @@ A jump table for the options with a short description can be found at |Q_op|. If non-zero, tags are significant up to this number of characters. *'tagrelative'* *'tr'* *'notagrelative'* *'notr'* -'tagrelative' 'tr' boolean (Vim default: on, Vi default: off) +'tagrelative' 'tr' boolean (default: on) global If on and using a tags file in another directory, file names in that tags file are relative to the directory where the tags file is. @@ -6837,7 +6829,7 @@ A jump table for the options with a short description can be found at |Q_op|. has been changed. *'whichwrap'* *'ww'* -'whichwrap' 'ww' string (Vim default: "b,s", Vi default: "") +'whichwrap' 'ww' string (default: "b,s") global Allow specified keys that move the cursor left/right to move to the previous/next line when the cursor is on the first/last character in @@ -6867,7 +6859,7 @@ A jump table for the options with a short description can be found at |Q_op|. makes "dl", "cl", "yl" etc. work normally. *'wildchar'* *'wc'* -'wildchar' 'wc' number (Vim default: <Tab>, Vi default: CTRL-E) +'wildchar' 'wc' number (default: <Tab>) global Character you have to type to start wildcard expansion in the command-line, as specified with 'wildmode'. @@ -7183,7 +7175,7 @@ A jump table for the options with a short description can be found at |Q_op|. starts. When typing text beyond this limit, an <EOL> will be inserted and inserting continues on the next line. Options that add a margin, such as 'number' and 'foldcolumn', cause - the text width to be further reduced. This is Vi compatible. + the text width to be further reduced. When 'textwidth' is non-zero, this option is not used. See also 'formatoptions' and |ins-textwidth|. diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 8369db7de1..ce3afba19b 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -971,7 +971,11 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest) */ last_line = curbuf->b_ml.ml_line_count; mark_adjust_nofold(line1, line2, last_line - line2, 0L, kExtmarkNOOP); + + disable_fold_update++; changed_lines(last_line - num_lines + 1, 0, last_line + 1, num_lines, false); + disable_fold_update--; + int line_off = 0; bcount_t byte_off = 0; if (dest >= line2) { @@ -1005,7 +1009,9 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest) mark_adjust_nofold(last_line - num_lines + 1, last_line, -(last_line - dest - extra), 0L, kExtmarkNOOP); + disable_fold_update++; changed_lines(last_line - num_lines + 1, 0, last_line + 1, -extra, false); + disable_fold_update--; // send update regarding the new lines that were added buf_updates_send_changes(curbuf, dest + 1, num_lines, 0, true); diff --git a/src/nvim/fold.c b/src/nvim/fold.c index 8a4a3bbbc0..9c8e92cd00 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -2003,7 +2003,7 @@ static void foldUpdateIEMS(win_T *const wp, linenr_T top, linenr_T bot) // start one line back, because a "<1" may indicate the end of a // fold in the topline if (top > 1) { - --fline.lnum; + fline.lnum--; } } else if (foldmethodIsSyntax(wp)) { getlevel = foldlevelSyntax; @@ -2011,6 +2011,12 @@ static void foldUpdateIEMS(win_T *const wp, linenr_T top, linenr_T bot) getlevel = foldlevelDiff; } else { getlevel = foldlevelIndent; + // Start one line back, because if the line above "top" has an + // undefined fold level, folding it relies on the line under it, + // which is "top". + if (top > 1) { + fline.lnum--; + } } // Backup to a line for which the fold level is defined. Since it's diff --git a/src/nvim/testdir/test_fold.vim b/src/nvim/testdir/test_fold.vim index da3e0ffc99..538b6b622e 100644 --- a/src/nvim/testdir/test_fold.vim +++ b/src/nvim/testdir/test_fold.vim @@ -921,6 +921,26 @@ func Test_fold_split() bw! endfunc +" Make sure that when you append under a blank line that is under a fold with +" the same indent level as your appended line, the fold expands across the +" blank line +func Test_indent_append_under_blank_line() + new + let lines =<< trim END + line 1 + line 2 + line 3 + END + call setline(1, lines) + setlocal sw=2 + setlocal foldmethod=indent foldenable + call assert_equal([0, 1, 1], range(1, 3)->map('foldlevel(v:val)')) + call append(3, '') + call append(4, ' line 5') + call assert_equal([0, 1, 1, 1, 1], range(1, 5)->map('foldlevel(v:val)')) + bw! +endfunc + " Make sure that when you delete 1 line of a fold whose length is 2 lines, the " fold can't be closed since its length (1) is now less than foldminlines. func Test_indent_one_line_fold_close() diff --git a/test/functional/legacy/prompt_buffer_spec.lua b/test/functional/legacy/prompt_buffer_spec.lua index 47eca19de3..63338b8dba 100644 --- a/test/functional/legacy/prompt_buffer_spec.lua +++ b/test/functional/legacy/prompt_buffer_spec.lua @@ -23,7 +23,7 @@ describe('prompt buffer', function() close else call append(line("$") - 1, 'Command: "' . a:text . '"') - set nomodfied + set nomodified call timer_start(20, {id -> TimerFunc(a:text)}) endif endfunc @@ -33,7 +33,7 @@ describe('prompt buffer', function() endfunc func SwitchWindows() - call timer_start(0, {-> execute("wincmd p|wincmd p", "")}) + call timer_start(0, {-> execute("wincmd p", "")}) endfunc ]]) feed_command("set noshowmode | set laststatus=0") @@ -187,7 +187,19 @@ describe('prompt buffer', function() -- INSERT -- | ]]) feed("<C-O>:call SwitchWindows()<CR>") - poke_eventloop() + screen:expect{grid=[[ + cmd: | + ~ | + ~ | + ~ | + [Prompt] [+] | + ^other buffer | + ~ | + ~ | + ~ | + | + ]]} + feed("<C-O>:call SwitchWindows()<CR>") screen:expect([[ cmd: ^ | ~ | @@ -201,7 +213,6 @@ describe('prompt buffer', function() -- INSERT -- | ]]) feed("<Esc>") - poke_eventloop() screen:expect([[ cmd:^ | ~ | diff --git a/test/functional/ui/bufhl_spec.lua b/test/functional/ui/bufhl_spec.lua index 9f84b71ece..7c0831bd09 100644 --- a/test/functional/ui/bufhl_spec.lua +++ b/test/functional/ui/bufhl_spec.lua @@ -564,6 +564,16 @@ describe('Buffer highlighting', function() ]] clear_namespace(id, 0, -1) + screen:expect{grid=[[ + fooba^r | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} set_extmark(id, 0, 0, { end_line = 0, diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index 9762805dee..394f2f5f49 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -1757,6 +1757,67 @@ describe("folded lines", function() end assert_alive() end) + + it('work correctly with :move #18668', function() + screen:try_resize(45, 12) + source([[ + set foldmethod=expr foldexpr=indent(v:lnum) + let content = ['', '', 'Line1', ' Line2', ' Line3', + \ 'Line4', ' Line5', ' Line6', + \ 'Line7', ' Line8', ' Line9'] + call append(0, content) + normal! zM + call cursor(4, 1) + move 2 + move 1 + ]]) + if multigrid then + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [3:---------------------------------------------]| + ## grid 2 + | + {5:^+-- 2 lines: Line2··························}| + | + Line1 | + Line4 | + {5:+-- 2 lines: Line5··························}| + Line7 | + {5:+-- 2 lines: Line8··························}| + | + {1:~ }| + {1:~ }| + ## grid 3 + | + ]]) + else + screen:expect([[ + | + {5:^+-- 2 lines: Line2··························}| + | + Line1 | + Line4 | + {5:+-- 2 lines: Line5··························}| + Line7 | + {5:+-- 2 lines: Line8··························}| + | + {1:~ }| + {1:~ }| + | + ]]) + end + end) end describe("with ext_multigrid", function() diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index 4f70aec691..ee49ae7a09 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -1227,7 +1227,6 @@ describe('ui/ext_messages', function() it('supports global statusline', function() feed(":set laststatus=3<cr>") feed(":sp<cr>") - feed("<c-l>") feed(":set cmdheight<cr>") screen:expect({grid=[[ ^ | @@ -1259,8 +1258,7 @@ describe('ui/ext_messages', function() }}) feed("<c-w>+") - feed("<c-l>") - feed(":set cmdheight<cr>") + feed(":set laststatus<cr>") screen:expect({grid=[[ ^ | {1:~ }| @@ -1287,7 +1285,7 @@ describe('ui/ext_messages', function() {1:~ }| {7:[No Name] }| ]], messages={ - {content = { { " cmdheight=0" } }, kind = "" } + {content = { { " laststatus=3" } }, kind = "" } }}) feed(":set mouse=a<cr>") diff --git a/test/functional/ui/searchhl_spec.lua b/test/functional/ui/searchhl_spec.lua index 56ff8a4101..cdb6256f77 100644 --- a/test/functional/ui/searchhl_spec.lua +++ b/test/functional/ui/searchhl_spec.lua @@ -43,7 +43,7 @@ describe('search highlighting', function() insert("some text\nmore text") feed_command('1,2fold') feed("gg/text") - screen:expect([[ + screen:expect{grid=[[ {6:+-- 2 lines: some text·················}| {1:~ }| {1:~ }| @@ -51,7 +51,9 @@ describe('search highlighting', function() {1:~ }| {1:~ }| /text^ | - ]]) + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 3, curline = 0, curcol = 9, linecount = 2}; + }} end) it('works', function() @@ -579,19 +581,20 @@ describe('search highlighting', function() end) it('works with matchadd and syntax', function() - screen:set_default_attr_ids( { - [1] = {bold=true, foreground=Screen.colors.Blue}, - [2] = {background = colors.Yellow}, - [3] = {reverse = true}, - [4] = {foreground = colors.Red}, - [5] = {bold = true, background = colors.Green}, - [6] = {italic = true, background = colors.Magenta}, - [7] = {bold = true, background = colors.Yellow}, - } ) + screen:set_default_attr_ids { + [1] = {bold=true, foreground=Screen.colors.Blue}; + [2] = {background = colors.Yellow}; + [3] = {reverse = true}; + [4] = {foreground = colors.Red}; + [5] = {bold = true, background = colors.Green}; + [6] = {italic = true, background = colors.Magenta}; + [7] = {bold = true, background = colors.Yellow}; + [8] = {foreground = Screen.colors.Blue4, background = Screen.colors.LightGray}; + } feed_command('set hlsearch') - insert([[ + insert [[ very special text - ]]) + ]] feed_command("syntax on") feed_command("highlight MyGroup guibg=Green gui=bold") feed_command("highlight MyGroup2 guibg=Magenta gui=italic") @@ -601,7 +604,7 @@ describe('search highlighting', function() -- searchhl and matchadd matches are exclusive, only the highest priority -- is used (and matches with lower priorities are not combined) feed_command("/ial te") - screen:expect([[ + screen:expect{grid=[[ very {5:spec^ial}{2: te}{6:xt} | | {1:~ }| @@ -609,10 +612,21 @@ describe('search highlighting', function() {1:~ }| {1:~ }| {4:search hit BOTTOM, continuing at TOP} | - ]]) + ]], win_viewport={ + [2] = {win = {id = 1000}, topline = 0, botline = 3, curline = 0, curcol = 11, linecount = 2}; + }} -- check highlights work also in folds feed("zf4j") + screen:expect{grid=[[ + {8:^+-- 2 lines: very special text·········}| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {4:search hit BOTTOM, continuing at TOP} | + ]]} command("%foldopen") screen:expect([[ very {5:spec^ial}{2: te}{6:xt} | diff --git a/test/functional/vimscript/execute_spec.lua b/test/functional/vimscript/execute_spec.lua index e21c71dc7f..a733b098f5 100644 --- a/test/functional/vimscript/execute_spec.lua +++ b/test/functional/vimscript/execute_spec.lua @@ -153,7 +153,7 @@ describe('execute()', function() function! Test3() echo 1234 let x = execute('echoerr "abcdef"', 'silent!') - echon 'ABCD' + echon 'ABCDXZYZ' endfunction " test 4: silenced echoerr goes as usual @@ -214,7 +214,7 @@ describe('execute()', function() ~ | ~ | ~ | - 1234ABCD | + 1234ABCDXZYZ | ]]) feed([[:call Test4()<cr>]]) |