diff options
69 files changed, 320 insertions, 148 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 2aed7d8b48..07c0f5a7af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -139,14 +139,14 @@ set_property(CACHE CMAKE_BUILD_TYPE PROPERTY # If not in a git repo (e.g., a tarball) these tokens define the complete # version string, else they are combined with the result of `git describe`. set(NVIM_VERSION_MAJOR 0) -set(NVIM_VERSION_MINOR 7) +set(NVIM_VERSION_MINOR 8) set(NVIM_VERSION_PATCH 0) set(NVIM_VERSION_PRERELEASE "-dev") # for package maintainers # API level set(NVIM_API_LEVEL 9) # Bump this after any API change. set(NVIM_API_LEVEL_COMPAT 0) # Adjust this after a _breaking_ API change. -set(NVIM_API_PRERELEASE true) +set(NVIM_API_PRERELEASE false) set(NVIM_VERSION_BUILD_TYPE "${CMAKE_BUILD_TYPE}") # NVIM_VERSION_CFLAGS set further below. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5e04f33b15..078377dcc2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,7 +11,7 @@ low-risk/isolated tasks: - Fix bugs found by [Clang](#clang-scan-build), [PVS](#pvs-studio) or [Coverity](#coverity). - [Improve documentation][wiki-contribute-help] -- [Merge a Vim patch] (Familiarity with Vim is *strongly* recommended) +- [Merge a Vim patch] (familiarity with Vim is *strongly* recommended) Reporting problems ------------------ @@ -289,7 +289,7 @@ as context, use the `-W` argument as well. [complexity:low]: https://github.com/neovim/neovim/issues?q=is%3Aopen+is%3Aissue+label%3Acomplexity%3Alow [master error list]: https://raw.githubusercontent.com/neovim/doc/gh-pages/reports/clint/errors.json [wiki-contribute-help]: https://github.com/neovim/neovim/wiki/contribute-%3Ahelp -[pr-draft]: https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request +[pr-draft]: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request [pr-ready]: https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-stage-of-a-pull-request [uncrustify]: http://uncrustify.sourceforge.net/ [lua-language-server]: https://github.com/sumneko/lua-language-server/ diff --git a/MAINTAIN.md b/MAINTAIN.md index 2b390270a9..927ddea5a1 100644 --- a/MAINTAIN.md +++ b/MAINTAIN.md @@ -52,7 +52,7 @@ has a major bug: 3. Cut a release from `release-x.y`. - Run `./scripts/release.sh` - Update (force-push) the remote `stable` tag. - - The [nightly job](https://github.com/neovim/bot-ci/blob/master/ci/nightly.sh) + - The [nightly job](https://github.com/neovim/neovim/blob/master/.github/workflows/release.yml#L4) will update the release assets based on the `stable` tag. The neovim repository includes a backport [github action](https://github.com/zeebe-io/backport-action). diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim index 866196a7df..975e2c23d8 100644 --- a/runtime/autoload/dist/ft.vim +++ b/runtime/autoload/dist/ft.vim @@ -823,7 +823,9 @@ func dist#ft#FTperl() endfunc func dist#ft#FTsys() - if IsRapid() + if exists("g:filetype_sys") + exe "setf " .. g:filetype_sys + elseif IsRapid() setf rapid else setf bat @@ -990,20 +992,23 @@ func dist#ft#FTtf() setf tf endfunc +let s:ft_krl_header = '\&\w+' " Determine if a *.src file is Kuka Robot Language func dist#ft#FTsrc() + let ft_krl_def_or_deffct = '%(global\s+)?def%(fct)?>' if exists("g:filetype_src") exe "setf " .. g:filetype_src - elseif getline(nextnonblank(1)) =~? '^\s*\%(&\w\+\|\%(global\s\+\)\?def\>\)' + elseif getline(nextnonblank(1)) =~? '\v^\s*%(' .. s:ft_krl_header .. '|' .. ft_krl_def_or_deffct .. ')' setf krl endif endfunc " Determine if a *.dat file is Kuka Robot Language func dist#ft#FTdat() + let ft_krl_defdat = 'defdat>' if exists("g:filetype_dat") exe "setf " .. g:filetype_dat - elseif getline(nextnonblank(1)) =~? '^\s*\%(&\w\+\|defdat\>\)' + elseif getline(nextnonblank(1)) =~? '\v^\s*%(' .. s:ft_krl_header .. '|' .. ft_krl_defdat .. ')' setf krl endif endfunc diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index 858258320d..9e0002db48 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -2859,8 +2859,7 @@ nvim_win_set_cursor({window}, {pos}) *nvim_win_set_cursor()* {pos} (row, col) tuple representing the new position nvim_win_set_height({window}, {height}) *nvim_win_set_height()* - Sets the window height. This will only succeed if the screen - is split horizontally. + Sets the window height. Parameters: ~ {window} Window handle, or 0 for current window @@ -3234,9 +3233,9 @@ nvim_create_autocmd({event}, {*opts}) *nvim_create_autocmd()* pattern = { "*.py", "*.pyi" } < - Examples values for event: > - "BufPreWrite" - {"CursorHold", "BufPreWrite", "BufPostWrite"} + Example values for event: > + "BufWritePre" + {"CursorHold", "BufWritePre", "BufWritePost"} < Parameters: ~ diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 49aa52a92f..7871885a5d 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -966,8 +966,6 @@ byteidxcomp({expr}, {nr}) *byteidxcomp()* < The first and third echo result in 3 ('e' plus composing character is 3 bytes), the second echo results in 1 ('e' is one byte). - Only works differently from byteidx() when 'encoding' is set - to a Unicode encoding. Can also be used as a |method|: > GetName()->byteidxcomp(idx) diff --git a/runtime/doc/filetype.txt b/runtime/doc/filetype.txt index 5f7c1b57f8..e1b0e88c95 100644 --- a/runtime/doc/filetype.txt +++ b/runtime/doc/filetype.txt @@ -153,6 +153,7 @@ variables can be used to overrule the filetype used for certain extensions: *.pp g:filetype_pp |ft-pascal-syntax| *.prg g:filetype_prg *.src g:filetype_src + *.sys g:filetype_sys *.sh g:bash_is_sh |ft-sh-syntax| *.tex g:tex_flavor |ft-tex-plugin| *.w g:filetype_w |ft-cweb-syntax| diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index 46b9f0576f..16f27486c8 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -1151,7 +1151,7 @@ In any of the above examples, to replicate the behavior |setlocal|, use |vim.opt| returns an Option object. -For example: `local listchar_object = vim.opt.listchar` +For example: `local listchar_object = vim.opt.listchars` An `Option` has the following methods: @@ -1910,7 +1910,7 @@ select({items}, {opts}, {on_choice}) *vim.ui.select()* which select() was called. {on_choice} function ((item|nil, idx|nil) -> ()) Called once the user made a choice. `idx` is the - 1-based index of `item` within `item`. `nil` + 1-based index of `item` within `items`. `nil` if the user aborted the dialog. diff --git a/runtime/doc/nvim_terminal_emulator.txt b/runtime/doc/nvim_terminal_emulator.txt index f322764ecf..9ac81e2916 100644 --- a/runtime/doc/nvim_terminal_emulator.txt +++ b/runtime/doc/nvim_terminal_emulator.txt @@ -45,11 +45,10 @@ by |:mksession| to restore a terminal buffer (by restarting the {cmd}). ============================================================================== Input *terminal-input* -To send input, enter |Terminal-mode| using any command that would enter "insert -mode" in a normal buffer, such as |i| or |:startinsert|. In this mode all keys -except <C-\> are sent to the underlying program. If <C-\> is pressed, the -next key is sent unless it is <C-N>. Use <C-\><C-N> to return to normal-mode. -|CTRL-\_CTRL-N| +To send input, enter |Terminal-mode| with |i|, |I|, |a|, |A| or +|:startinsert|. In this mode all keys except <C-\> are sent to the underlying +program. If <C-\> is pressed, the next key is sent unless it is <C-N>. Use +<C-\><C-N> to return to normal-mode. |CTRL-\_CTRL-N| Terminal-mode forces these local options: diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 8d353804a4..7ea6a92a34 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -921,7 +921,7 @@ A jump table for the options with a short description can be found at |Q_op|. Note that environment variables are not expanded. If you want to use $HOME you must expand it explicitly, e.g.: > - :let backupskip = escape(expand('$HOME'), '\') .. '/tmp/*' + :let &backupskip = escape(expand('$HOME'), '\') .. '/tmp/*' < Note that the default also makes sure that "crontab -e" works (when a backup would be made by renaming the original file crontab won't see diff --git a/runtime/doc/term.txt b/runtime/doc/term.txt index ddf52b65c6..bdf0094721 100644 --- a/runtime/doc/term.txt +++ b/runtime/doc/term.txt @@ -111,7 +111,7 @@ width of the terminal. *tui-input* Nvim uses libtermkey to convert terminal escape sequences to key codes. |terminfo| is used first, and CSI sequences not in |terminfo| (including -exteneded keys a.k.a. modifyOtherKeys or `CSI u`) can also be parsed. +extended keys a.k.a. modifyOtherKeys or `CSI u`) can also be parsed. For example, when running Nvim in tmux, this makes Nvim leave Insert mode and go to the window below: > tmux send-keys 'Escape' [ 2 7 u 'C-W' j diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt index a9d9f81849..b10bf3498d 100644 --- a/runtime/doc/treesitter.txt +++ b/runtime/doc/treesitter.txt @@ -268,7 +268,7 @@ Here is a list of built-in directives: ((identifier) @foo (#set! @foo "kind" "parameter")) ((node1) @left (node2) @right (#set! "type" "pair")) < - `offset!` *ts-predicate-offset!* + `offset!` *ts-directive-offset!* Takes the range of the captured node and applies the offsets to it's range : > ((identifier) @constant (#offset! @constant 0 1 0 -1)) diff --git a/runtime/filetype.vim b/runtime/filetype.vim index f7c0317eff..5e73374649 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1271,6 +1271,9 @@ au BufNewFile,BufRead *.or setf openroad " OPL au BufNewFile,BufRead *.[Oo][Pp][Ll] setf opl +" OpenSCAD +au BufNewFile,BufRead *.scad setf openscad + " Oracle config file au BufNewFile,BufRead *.ora setf ora @@ -1280,13 +1283,13 @@ au BufNewFile,BufRead *.org,*.org_archive setf org " Packet filter conf au BufNewFile,BufRead pf.conf setf pf -" Pacman Config (close enough to dosini) -au BufNewFile,BufRead */etc/pacman.conf setf dosini +" Pacman config +au BufNewFile,BufRead */etc/pacman.conf setf conf " Pacman hooks au BufNewFile,BufRead *.hook \ if getline(1) == '[Trigger]' | - \ setf dosini | + \ setf conf | \ endif " Pam conf diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua index d4db4850bd..8e372b806c 100644 --- a/runtime/lua/vim/_editor.lua +++ b/runtime/lua/vim/_editor.lua @@ -174,11 +174,11 @@ do if vim.fn.getcmdtype() ~= '' then -- cmdline-mode: paste only 1 line. if not got_line1 then got_line1 = (#lines > 1) - vim.api.nvim_set_option('paste', true) -- For nvim_input(). - -- Escape "<" and control characters - local line1 = lines[1]:gsub('<', '<lt>'):gsub('(%c)', '\022%1') - vim.api.nvim_input(line1) - vim.api.nvim_set_option('paste', false) + -- Escape control characters + local line1 = lines[1]:gsub('(%c)', '\022%1') + -- nvim_input() is affected by mappings, + -- so use nvim_feedkeys() with "n" flag to ignore mappings. + vim.api.nvim_feedkeys(line1, 'n', true) end return true end diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 603f9f854a..d8d4afb6c2 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -103,6 +103,11 @@ local extension = { cbl = "cobol", atg = "coco", recipe = "conaryrecipe", + hook = function(path, bufnr) + if getline(bufnr, 1) == '[Trigger]' then + return "conf" + end + end, mklx = "context", mkiv = "context", mkii = "context", @@ -436,6 +441,7 @@ local extension = { xin = "omnimark", opam = "opam", ["or"] = "openroad", + scad = "openscad", ora = "ora", org = "org", org_archive = "org", @@ -902,7 +908,7 @@ local filename = { Dockerfile = "dockerfile", npmrc = "dosini", ["/etc/yum.conf"] = "dosini", - ["/etc/pacman.conf"] = "dosini", + ["/etc/pacman.conf"] = "conf", [".npmrc"] = "dosini", [".editorconfig"] = "dosini", dune = "dune", @@ -1181,7 +1187,7 @@ local pattern = { [".*/etc/DIR_COLORS"] = "dircolors", [".*/etc/dnsmasq%.conf"] = "dnsmasq", ["php%.ini%-.*"] = "dosini", - [".*/etc/pacman%.conf"] = "dosini", + [".*/etc/pacman%.conf"] = "conf", [".*/etc/yum%.conf"] = "dosini", [".*lvs"] = "dracula", [".*lpe"] = "dracula", diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua index f5aefd4402..9871f00677 100644 --- a/runtime/lua/vim/lsp/handlers.lua +++ b/runtime/lua/vim/lsp/handlers.lua @@ -141,7 +141,7 @@ M['workspace/configuration'] = function(_, result, ctx) local response = {} for _, item in ipairs(result.items) do if item.section then - local value = util.lookup_section(client.config.settings, item.section) or vim.NIL + local value = util.lookup_section(client.config.settings, item.section) -- For empty sections with no explicit '' key, return settings as is if value == vim.NIL and item.section == '' then value = client.config.settings or vim.NIL diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index 401dac9acd..30587afb38 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -1950,8 +1950,8 @@ end function M.lookup_section(settings, section) for part in vim.gsplit(section, '.', true) do settings = settings[part] - if not settings then - return + if settings == nil then + return vim.NIL end end return settings diff --git a/runtime/lua/vim/ui.lua b/runtime/lua/vim/ui.lua index 9d4b38f08a..165dada1b8 100644 --- a/runtime/lua/vim/ui.lua +++ b/runtime/lua/vim/ui.lua @@ -16,7 +16,7 @@ local M = {} --- `items`, or the context in which select() was called. ---@param on_choice function ((item|nil, idx|nil) -> ()) --- Called once the user made a choice. ---- `idx` is the 1-based index of `item` within `item`. +--- `idx` is the 1-based index of `item` within `items`. --- `nil` if the user aborted the dialog. --- --- diff --git a/runtime/nvim.appdata.xml b/runtime/nvim.appdata.xml index 4ad656f1a3..1464c27694 100644 --- a/runtime/nvim.appdata.xml +++ b/runtime/nvim.appdata.xml @@ -26,6 +26,7 @@ </screenshots> <releases> + <release date="2022-04-15" version="0.7.0"/> <release date="2021-12-31" version="0.6.1"/> <release date="2021-11-30" version="0.6.0"/> <release date="2021-09-26" version="0.5.1"/> diff --git a/scripts/lua2dox.lua b/scripts/lua2dox.lua index d110e34c6a..c32370517c 100644 --- a/scripts/lua2dox.lua +++ b/scripts/lua2dox.lua @@ -295,7 +295,7 @@ function TStream_Write.writelnTail(this,Line) table.insert(this.tailLine,Line) end ---! \brief outout tail lines +--! \brief output tail lines function TStream_Write.write_tailLines(this) for _,line in ipairs(this.tailLine) do TCore_IO_writeln(line) diff --git a/src/nvim/README.md b/src/nvim/README.md index 4efb42b896..c7cb233c73 100644 --- a/src/nvim/README.md +++ b/src/nvim/README.md @@ -68,7 +68,7 @@ Configure the sanitizer(s) via these environment variables: export ASAN_OPTIONS="detect_leaks=0:log_path=$HOME/logs/asan" # Show backtraces in the logs. export UBSAN_OPTIONS=print_stacktrace=1 - export MSAN_OPTIONS="log_path=${HOME}/logs/tsan" + export MSAN_OPTIONS="log_path=${HOME}/logs/msan" export TSAN_OPTIONS="log_path=${HOME}/logs/tsan" Logs will be written to `${HOME}/logs/*san.PID` then. diff --git a/src/nvim/api/autocmd.c b/src/nvim/api/autocmd.c index ccf4ae3d02..a012f3d7fc 100644 --- a/src/nvim/api/autocmd.c +++ b/src/nvim/api/autocmd.c @@ -360,10 +360,10 @@ cleanup: /// pattern = { "*.py", "*.pyi" } /// </pre> /// -/// Examples values for event: +/// Example values for event: /// <pre> -/// "BufPreWrite" -/// {"CursorHold", "BufPreWrite", "BufPostWrite"} +/// "BufWritePre" +/// {"CursorHold", "BufWritePre", "BufWritePost"} /// </pre> /// /// @param event (string|array) The event or events to register this autocommand diff --git a/src/nvim/api/window.c b/src/nvim/api/window.c index fd33a82be3..3a3a65f812 100644 --- a/src/nvim/api/window.c +++ b/src/nvim/api/window.c @@ -139,8 +139,7 @@ Integer nvim_win_get_height(Window window, Error *err) return win->w_height; } -/// Sets the window height. This will only succeed if the screen is split -/// horizontally. +/// Sets the window height. /// /// @param window Window handle, or 0 for current window /// @param height Height as a count of rows diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 4948e2bb69..4d914acea4 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -1775,19 +1775,6 @@ buf_T *buflist_new(char_u *ffname_arg, char_u *sfname_arg, linenr_T lnum, int fl clear_wininfo(buf); buf->b_wininfo = xcalloc(1, sizeof(wininfo_T)); - if (ffname != NULL && (buf->b_ffname == NULL || buf->b_sfname == NULL)) { - if (buf->b_sfname != buf->b_ffname) { - XFREE_CLEAR(buf->b_sfname); - } else { - buf->b_sfname = NULL; - } - XFREE_CLEAR(buf->b_ffname); - if (buf != curbuf) { - free_buffer(buf); - } - return NULL; - } - if (buf == curbuf) { // free all things allocated for this buffer buf_freeall(buf, 0); diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index eb5c6e503a..0fadc0d220 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -3017,11 +3017,12 @@ void ex_call(exarg_T *eap) } } - // When inside :try we need to check for following "| catch". - if (!failed || eap->cstack->cs_trylevel > 0) { + // When inside :try we need to check for following "| catch" or "| endtry". + // Not when there was an error, but do check if an exception was thrown. + if ((!aborting() || current_exception != NULL) && (!failed || eap->cstack->cs_trylevel > 0)) { // Check for trailing illegal characters and a following command. if (!ends_excmd(*arg)) { - if (!failed) { + if (!failed && !aborting()) { emsg_severe = true; emsg(_(e_trailing)); } diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 98aabe89b3..61bd9571b5 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -4328,7 +4328,7 @@ skip: } \ kv_push(preview_lines.subresults, current_match); \ } \ - } while (0) + } while (0) // Push the match to preview_lines. PUSH_PREVIEW_LINES(); @@ -4593,9 +4593,7 @@ void ex_global(exarg_T *eap) return; } else { delim = *cmd; // get the delimiter - if (delim) { - ++cmd; // skip delimiter if there is one - } + cmd++; // skip delimiter if there is one pat = cmd; // remember start of pattern cmd = skip_regexp(cmd, delim, p_magic, &eap->arg); if (cmd[0] == delim) { // end delimiter found diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index cbfe6e3789..fc0bb48803 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -2373,8 +2373,13 @@ int parse_cmd_address(exarg_T *eap, char **errormsg, bool silent) switch (eap->addr_type) { case ADDR_LINES: case ADDR_OTHER: - // default is current line number - eap->line2 = curwin->w_cursor.lnum; + // Default is the cursor line number. Avoid using an invalid + // line number though. + if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) { + eap->line2 = curbuf->b_ml.ml_line_count; + } else { + eap->line2 = curwin->w_cursor.lnum; + } break; case ADDR_WINDOWS: eap->line2 = CURRENT_WIN_NR; diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index 3c7c635d98..f4aaab5c43 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -1083,7 +1083,7 @@ void ex_endwhile(exarg_T *eap) if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0) { eap->errmsg = err; } else { - fl = cstack->cs_flags[cstack->cs_idx]; + fl = cstack->cs_flags[cstack->cs_idx]; if (!(fl & csf)) { // If we are in a ":while" or ":for" but used the wrong endloop // command, do not rewind to the next enclosing ":for"/":while". @@ -1575,6 +1575,7 @@ void ex_endtry(exarg_T *eap) if (!(cstack->cs_flags[cstack->cs_idx] & CSF_TRY)) { eap->errmsg = get_end_emsg(cstack); + // Find the matching ":try" and report what's missing. idx = cstack->cs_idx; do { @@ -1594,6 +1595,9 @@ void ex_endtry(exarg_T *eap) if (current_exception) { discard_current_exception(); } + + // report eap->errmsg, also when there already was an error + did_emsg = false; } else { idx = cstack->cs_idx; @@ -1664,8 +1668,10 @@ void ex_endtry(exarg_T *eap) */ (void)cleanup_conditionals(cstack, CSF_TRY | CSF_SILENT, TRUE); - --cstack->cs_idx; - --cstack->cs_trylevel; + if (cstack->cs_idx >= 0 && (cstack->cs_flags[cstack->cs_idx] & CSF_TRY)) { + cstack->cs_idx--; + } + cstack->cs_trylevel--; if (!skip) { report_resume_pending(pending, @@ -1913,7 +1919,7 @@ int cleanup_conditionals(cstack_T *cstack, int searched_cond, int inclusive) default: if (cstack->cs_flags[idx] & CSF_FINALLY) { - if (cstack->cs_pending[idx] & CSTP_THROW) { + if ((cstack->cs_pending[idx] & CSTP_THROW) && cstack->cs_exception[idx] != NULL) { // Cancel the pending exception. This is in the // finally clause, so that the stack of the // caught exceptions is not involved. @@ -1934,8 +1940,9 @@ int cleanup_conditionals(cstack_T *cstack, int searched_cond, int inclusive) */ if (!(cstack->cs_flags[idx] & CSF_FINALLY)) { if ((cstack->cs_flags[idx] & CSF_ACTIVE) - && (cstack->cs_flags[idx] & CSF_CAUGHT)) { + && (cstack->cs_flags[idx] & CSF_CAUGHT) && !(cstack->cs_flags[idx] & CSF_FINISHED)) { finish_exception((except_T *)cstack->cs_exception[idx]); + cstack->cs_flags[idx] |= CSF_FINISHED; } // Stop at this try conditional - except the try block never // got active (because of an inactive surrounding conditional diff --git a/src/nvim/ex_eval.h b/src/nvim/ex_eval.h index 15da4b2d60..1cd0a47d7a 100644 --- a/src/nvim/ex_eval.h +++ b/src/nvim/ex_eval.h @@ -14,9 +14,10 @@ #define CSF_TRY 0x0100 // is a ":try" #define CSF_FINALLY 0x0200 // ":finally" has been passed -#define CSF_THROWN 0x0400 // exception thrown to this try conditional -#define CSF_CAUGHT 0x0800 // exception caught by this try conditional -#define CSF_SILENT 0x1000 // "emsg_silent" reset by ":try" +#define CSF_THROWN 0x0800 // exception thrown to this try conditional +#define CSF_CAUGHT 0x1000 // exception caught by this try conditional +#define CSF_FINISHED 0x2000 // CSF_CAUGHT was handled by finish_exception() +#define CSF_SILENT 0x4000 // "emsg_silent" reset by ":try" // Note that CSF_ELSE is only used when CSF_TRY and CSF_WHILE are unset // (an ":if"), and CSF_SILENT is only used when CSF_TRY is set. diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 33e71115a4..91e93a236a 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -5854,7 +5854,7 @@ HistoryType get_histtype(const char *const name, const size_t len, const bool re static int last_maptick = -1; // last seen maptick /// Add the given string to the given history. If the string is already in the -/// history then it is moved to the front. "histype" may be one of he HIST_ +/// history then it is moved to the front. "histype" may be one of the HIST_ /// values. /// /// @parma in_map consider maptick when inside a mapping diff --git a/src/nvim/highlight_group.c b/src/nvim/highlight_group.c index d448f3a646..3092aaefab 100644 --- a/src/nvim/highlight_group.c +++ b/src/nvim/highlight_group.c @@ -446,7 +446,7 @@ const char *const highlight_init_cmdline[] = { "default link NvimInvalidSpacing ErrorMsg", - // Not actually invalid, but we highlight user that he is doing something + // Not actually invalid, but we show the user that they are doing something // wrong. "default link NvimDoubleQuotedUnknownEscape NvimInvalidValue", NULL, diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 5f6e1ea273..55480ab384 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -3944,10 +3944,8 @@ static void ml_updatechunk(buf_T *buf, linenr_T line, long len, int updtype) } else if (buf->b_ml.ml_chunksize[curix].mlcs_numlines >= MLCS_MINL && curix == buf->b_ml.ml_usedchunks - 1 && buf->b_ml.ml_line_count - line <= 1) { - /* - * We are in the last chunk and it is cheap to crate a new one - * after this. Do it now to avoid the loop above later on - */ + // We are in the last chunk and it is cheap to create a new one + // after this. Do it now to avoid the loop above later on curchnk = buf->b_ml.ml_chunksize + curix + 1; buf->b_ml.ml_usedchunks++; if (line == buf->b_ml.ml_line_count) { diff --git a/src/nvim/normal.c b/src/nvim/normal.c index a8769c4c80..d6b3b53c86 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -4533,7 +4533,7 @@ static void nv_scroll(cmdarg_T *cap) validate_botline(curwin); // make sure w_empty_rows is valid half = (curwin->w_height_inner - curwin->w_empty_rows + 1) / 2; for (n = 0; curwin->w_topline + n < curbuf->b_ml.ml_line_count; n++) { - // Count half he number of filler lines to be "below this + // Count half the number of filler lines to be "below this // line" and half to be "above the next line". if (n > 0 && used + win_get_fill(curwin, curwin->w_topline + n) / 2 >= half) { n--; diff --git a/src/nvim/option.c b/src/nvim/option.c index f6037fc20a..897c12a6c4 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -335,6 +335,9 @@ static char_u SHM_ALL[] = { 0, }; +static char e_unclosed_expression_sequence[] = N_("E540: Unclosed expression sequence"); +static char e_unbalanced_groups[] = N_("E542: unbalanced groups"); + #ifdef INCLUDE_GENERATED_DECLARATIONS # include "option.c.generated.h" #endif @@ -2661,9 +2664,7 @@ ambw_end: int x2 = -1; int x3 = -1; - if (*p != NUL) { - p += utfc_ptr2len(p); - } + p += utfc_ptr2len(p); if (*p != NUL) { x2 = *p++; } @@ -2920,8 +2921,8 @@ ambw_end: curbuf->b_help = (curbuf->b_p_bt[0] == 'h'); redraw_titles(); } - } else if (gvarp == &p_stl || varp == &p_ruf) { - // 'statusline' or 'rulerformat' + } else if (gvarp == &p_stl || varp == &p_tal || varp == &p_ruf) { + // 'statusline', 'tabline' or 'rulerformat' int wid; if (varp == &p_ruf) { // reset ru_wid first @@ -2940,7 +2941,7 @@ ambw_end: errmsg = check_stl_option(p_ruf); } } else if (varp == &p_ruf || s[0] != '%' || s[1] != '!') { - // check 'statusline' only if it doesn't start with "%!" + // check 'statusline' or 'tabline' only if it doesn't start with "%!" errmsg = check_stl_option(s); } if (varp == &p_ruf && errmsg == NULL) { @@ -3726,7 +3727,7 @@ static char *set_chars_option(win_T *wp, char_u **varp, bool set) } /// Check validity of options with the 'statusline' format. -/// Return error message or NULL. +/// Return an untranslated error message or NULL. char *check_stl_option(char_u *s) { int groupdepth = 0; @@ -3775,18 +3776,22 @@ char *check_stl_option(char_u *s) return illegal_char(errbuf, sizeof(errbuf), *s); } if (*s == '{') { - int reevaluate = (*s == '%'); - s++; + bool reevaluate = (*++s == '%'); + + if (reevaluate && *++s == '}') { + // "}" is not allowed immediately after "%{%" + return illegal_char(errbuf, sizeof(errbuf), '}'); + } while ((*s != '}' || (reevaluate && s[-1] != '%')) && *s) { s++; } if (*s != '}') { - return N_("E540: Unclosed expression sequence"); + return e_unclosed_expression_sequence; } } } if (groupdepth != 0) { - return N_("E542: unbalanced groups"); + return e_unbalanced_groups; } return NULL; } diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index b738d36234..e958a39ad2 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -715,7 +715,7 @@ void expand_env_esc(char_u *restrict srcp, char_u *restrict dst, int dstlen, boo int c = (int)STRLEN(var); // if var[] ends in a path separator and tail[] starts // with it, skip a character - if (*var != NUL && after_pathsep((char *)dst, (char *)dst + c) + if (after_pathsep((char *)dst, (char *)dst + c) #if defined(BACKSLASH_IN_FILENAME) && dst[-1] != ':' #endif diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 4ad5e40fee..f8d2d37a91 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -103,7 +103,7 @@ typedef struct qf_list_S { char_u *qf_title; ///< title derived from the command that created ///< the error list or set by setqflist typval_T *qf_ctx; ///< context set by setqflist/setloclist - Callback qftf_cb; ///< 'quickfixtextfunc' callback function + Callback qf_qftf_cb; ///< 'quickfixtextfunc' callback function struct dir_stack_T *qf_dir_stack; char_u *qf_directory; @@ -2040,7 +2040,7 @@ static int copy_loclist(qf_list_T *from_qfl, qf_list_T *to_qfl) } else { to_qfl->qf_ctx = NULL; } - callback_copy(&to_qfl->qftf_cb, &from_qfl->qftf_cb); + callback_copy(&to_qfl->qf_qftf_cb, &from_qfl->qf_qftf_cb); if (from_qfl->qf_count) { if (copy_loclist_entries(from_qfl, to_qfl) == FAIL) { @@ -3448,7 +3448,7 @@ static void qf_free(qf_list_T *qfl) XFREE_CLEAR(qfl->qf_title); tv_free(qfl->qf_ctx); qfl->qf_ctx = NULL; - callback_free(&qfl->qftf_cb); + callback_free(&qfl->qf_qftf_cb); qfl->qf_id = 0; qfl->qf_changedtick = 0L; } @@ -4109,10 +4109,10 @@ static list_T *call_qftf_func(qf_list_T *qfl, int qf_winid, long start_idx, long // If 'quickfixtextfunc' is set, then use the user-supplied function to get // the text to display. Use the local value of 'quickfixtextfunc' if it is // set. - if (qfl->qftf_cb.type != kCallbackNone) { - cb = &qfl->qftf_cb; + if (qfl->qf_qftf_cb.type != kCallbackNone) { + cb = &qfl->qf_qftf_cb; } - if (cb != NULL && cb->type != kCallbackNone) { + if (cb->type != kCallbackNone) { typval_T args[1]; typval_T rettv; @@ -6258,10 +6258,10 @@ static int qf_getprop_qftf(qf_list_T *qfl, dict_T *retdict) { int status; - if (qfl->qftf_cb.type != kCallbackNone) { + if (qfl->qf_qftf_cb.type != kCallbackNone) { typval_T tv; - callback_put(&qfl->qftf_cb, &tv); + callback_put(&qfl->qf_qftf_cb, &tv); status = tv_dict_add_tv(retdict, S_LEN("quickfixtextfunc"), &tv); tv_clear(&tv); } else { @@ -6361,9 +6361,9 @@ static int qf_setprop_qftf(qf_list_T *qfl, dictitem_T *di) { Callback cb; - callback_free(&qfl->qftf_cb); + callback_free(&qfl->qf_qftf_cb); if (callback_from_typval(&cb, &di->di_tv)) { - qfl->qftf_cb = cb; + qfl->qf_qftf_cb = cb; } return OK; } diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 296255ed8c..c6fd9e5dff 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -4840,7 +4840,7 @@ static int get_corner_sep_connector(win_T *wp, WindowCorner corner) } } -/// Draw seperator connecting characters on the corners of window "wp" +/// Draw separator connecting characters on the corners of window "wp" static void draw_sep_connectors_win(win_T *wp) { // Don't draw separator connectors unless global statusline is enabled and the window has @@ -5173,19 +5173,19 @@ static void win_redr_status(win_T *wp) *(p + len++) = ' '; } if (bt_help(wp->w_buffer)) { - STRCPY(p + len, _("[Help]")); + snprintf((char *)p + len, MAXPATHL - len, "%s", _("[Help]")); len += (int)STRLEN(p + len); } if (wp->w_p_pvw) { - STRCPY(p + len, _("[Preview]")); + snprintf((char *)p + len, MAXPATHL - len, "%s", _("[Preview]")); len += (int)STRLEN(p + len); } if (bufIsChanged(wp->w_buffer)) { - STRCPY(p + len, "[+]"); - len += 3; + snprintf((char *)p + len, MAXPATHL - len, "%s", "[+]"); + len += (int)STRLEN(p + len); } if (wp->w_buffer->b_p_ro) { - STRCPY(p + len, _("[RO]")); + snprintf((char *)p + len, MAXPATHL - len, "%s", _("[RO]")); // len += (int)STRLEN(p + len); // dead assignment } diff --git a/src/nvim/screen.h b/src/nvim/screen.h index 5e86dacd25..330ff1d4a1 100644 --- a/src/nvim/screen.h +++ b/src/nvim/screen.h @@ -27,7 +27,7 @@ typedef enum { WC_BOTTOM_RIGHT } WindowCorner; -/// By default, all widows are draw on a single rectangular grid, represented by +/// By default, all windows are drawn on a single rectangular grid, represented by /// this ScreenGrid instance. In multigrid mode each window will have its own /// grid, then this is only used for global screen elements that hasn't been /// externalized. diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index d884ad704b..0ceb66f438 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -5802,8 +5802,8 @@ char_u *get_syntax_name(expand_T *xp, int idx) int syn_get_id(win_T *wp, long lnum, colnr_T col, int trans, bool *spellp, int keep_state) { // When the position is not after the current position and in the same - // line of the same buffer, need to restart parsing. - if (wp->w_buffer != syn_buf || lnum != current_lnum || col < current_col) { + // line of the same window with the same buffer, need to restart parsing. + if (wp != syn_win || wp->w_buffer != syn_buf || lnum != current_lnum || col < current_col) { syntax_start(wp, lnum); } else if (col > current_col) { // next_match may not be correct when moving around, e.g. with the diff --git a/src/nvim/testdir/test_breakindent.vim b/src/nvim/testdir/test_breakindent.vim index 438edb0257..a37751e748 100644 --- a/src/nvim/testdir/test_breakindent.vim +++ b/src/nvim/testdir/test_breakindent.vim @@ -770,7 +770,7 @@ func Test_breakindent20_list() \ "shall make no law ", \ ] call s:compare_lines(expect, lines) - " set mininum indent + " set minimum indent setl briopt=min:5 redraw! let lines = s:screen_lines2(1, 6, 20) diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index c589d941da..5c2f6f8d0b 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -1127,7 +1127,7 @@ func Test_cmdwin_tabpage() tabedit " v8.2.1919 isn't ported yet, so E492 is thrown after E11 here. " v8.2.1183 also isn't ported yet, so we also can't assert E11 directly. - " For now, assert E11 and E492 seperately. When v8.2.1183 is ported, the + " For now, assert E11 and E492 separately. When v8.2.1183 is ported, the " assert for E492 will fail and this workaround should be removed. " call assert_fails("silent norm q/g :I\<Esc>", 'E11:') call assert_fails("silent norm q/g ", 'E11:') diff --git a/src/nvim/testdir/test_debugger.vim b/src/nvim/testdir/test_debugger.vim index a396efc09e..e038c0096a 100644 --- a/src/nvim/testdir/test_debugger.vim +++ b/src/nvim/testdir/test_debugger.vim @@ -976,7 +976,7 @@ func Test_debug_backtrace_level() \ 'line 1: let s:file1_var = ''file1''' \ ]) - " step throught the initial declarations + " step through the initial declarations call RunDbgCmd(buf, 'step', [ 'line 2: let g:global_var = ''global''' ] ) call RunDbgCmd(buf, 'step', [ 'line 4: func s:File1Func( arg )' ] ) call RunDbgCmd(buf, 'echo s:file1_var', [ 'file1' ] ) diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim index 197a9edb76..bf6226c6b3 100644 --- a/src/nvim/testdir/test_filetype.vim +++ b/src/nvim/testdir/test_filetype.vim @@ -113,7 +113,7 @@ let s:filename_checks = { \ 'cobol': ['file.cbl', 'file.cob', 'file.lib'], \ 'coco': ['file.atg'], \ 'conaryrecipe': ['file.recipe'], - \ 'conf': ['auto.master'], + \ 'conf': ['/etc/pacman.conf', 'any/etc/pacman.conf', 'auto.master'], \ 'config': ['configure.in', 'configure.ac', '/etc/hostname.file'], \ 'context': ['tex/context/any/file.tex', 'file.mkii', 'file.mkiv', 'file.mkvi', 'file.mkxl', 'file.mklx'], \ 'cook': ['file.cook'], @@ -152,7 +152,7 @@ let s:filename_checks = { \ 'dnsmasq': ['/etc/dnsmasq.conf', '/etc/dnsmasq.d/file', 'any/etc/dnsmasq.conf', 'any/etc/dnsmasq.d/file'], \ 'dockerfile': ['Containerfile', 'Dockerfile', 'file.Dockerfile', 'Dockerfile.debian', 'Containerfile.something'], \ 'dosbatch': ['file.bat'], - \ 'dosini': ['.editorconfig', '/etc/pacman.conf', '/etc/yum.conf', 'file.ini', 'npmrc', '.npmrc', 'php.ini', 'php.ini-5', 'php.ini-file', '/etc/yum.repos.d/file', 'any/etc/pacman.conf', 'any/etc/yum.conf', 'any/etc/yum.repos.d/file', 'file.wrap'], + \ 'dosini': ['.editorconfig', '/etc/yum.conf', 'file.ini', 'npmrc', '.npmrc', 'php.ini', 'php.ini-5', 'php.ini-file', '/etc/yum.repos.d/file', 'any/etc/yum.conf', 'any/etc/yum.repos.d/file', 'file.wrap'], \ 'dot': ['file.dot', 'file.gv'], \ 'dracula': ['file.drac', 'file.drc', 'filelvs', 'filelpe', 'drac.file', 'lpe', 'lvs', 'some-lpe', 'some-lvs'], \ 'dtd': ['file.dtd'], @@ -383,6 +383,7 @@ let s:filename_checks = { \ 'omnimark': ['file.xom', 'file.xin'], \ 'opam': ['opam', 'file.opam', 'file.opam.template'], \ 'openroad': ['file.or'], + \ 'openscad': ['file.scad'], \ 'ora': ['file.ora'], \ 'org': ['file.org', 'file.org_archive'], \ 'pamconf': ['/etc/pam.conf', '/etc/pam.d/file', 'any/etc/pam.conf', 'any/etc/pam.d/file'], @@ -743,7 +744,7 @@ func Test_setfiletype_completion() endfunc """"""""""""""""""""""""""""""""""""""""""""""""" -" Tests for specific extentions and filetypes. +" Tests for specific extensions and filetypes. " Keep sorted. """"""""""""""""""""""""""""""""""""""""""""""""" @@ -1171,12 +1172,12 @@ func Test_hook_file() call writefile(['[Trigger]', 'this is pacman config'], 'Xfile.hook') split Xfile.hook - call assert_equal('dosini', &filetype) + call assert_equal('conf', &filetype) bwipe! call writefile(['not pacman'], 'Xfile.hook') split Xfile.hook - call assert_notequal('dosini', &filetype) + call assert_notequal('conf', &filetype) bwipe! call delete('Xfile.hook') @@ -1474,7 +1475,7 @@ endfunc func Test_sc_file() filetype on - " SC file mehtods are defined 'Class : Method' + " SC file methods are defined 'Class : Method' call writefile(['SCNvimDocRenderer : SCDocHTMLRenderer {'], 'srcfile.sc') split srcfile.sc call assert_equal('supercollider', &filetype) @@ -1535,11 +1536,13 @@ func Test_src_file() bwipe! call delete('srcfile.Src') - " KRL global def with embedded spaces, file starts with empty line(s). - call writefile(['', 'global def srcfile()'], 'srcfile.SRC') - split srcfile.SRC - call assert_equal('krl', &filetype) - bwipe! + " KRL global deffct with embedded spaces, file starts with empty line(s). + for text in ['global def srcfile()', 'global deffct srcfile()'] + call writefile(['', text], 'srcfile.SRC') + split srcfile.SRC + call assert_equal('krl', &filetype, text) + bwipe! + endfor " User may overrule file inspection let g:filetype_src = 'src' @@ -1561,6 +1564,13 @@ func Test_sys_file() call assert_equal('bat', &filetype) bwipe! + " Users preference set by g:filetype_sys + let g:filetype_sys = 'sys' + split sysfile.sys + call assert_equal('sys', &filetype) + unlet g:filetype_sys + bwipe! + " RAPID header start with a line containing only "%%%", " but is not always present. call writefile(['%%%'], 'sysfile.sys') diff --git a/src/nvim/testdir/test_increment.vim b/src/nvim/testdir/test_increment.vim index 6d08cd40a8..12fe52f057 100644 --- a/src/nvim/testdir/test_increment.vim +++ b/src/nvim/testdir/test_increment.vim @@ -285,7 +285,7 @@ endfunc " 1 " 1 " 1 -" Expexted: +" Expected: " 1) g Ctrl-A on block selected indented lines " 2 " 1 diff --git a/src/nvim/testdir/test_options.vim b/src/nvim/testdir/test_options.vim index 8612b7013b..d16d89ec2e 100644 --- a/src/nvim/testdir/test_options.vim +++ b/src/nvim/testdir/test_options.vim @@ -281,8 +281,16 @@ func Test_set_errors() call assert_fails('set rulerformat=%15(%%', 'E542:') call assert_fails('set statusline=%$', 'E539:') call assert_fails('set statusline=%{', 'E540:') + call assert_fails('set statusline=%{%', 'E540:') + call assert_fails('set statusline=%{%}', 'E539:') call assert_fails('set statusline=%(', 'E542:') call assert_fails('set statusline=%)', 'E542:') + call assert_fails('set tabline=%$', 'E539:') + call assert_fails('set tabline=%{', 'E540:') + call assert_fails('set tabline=%{%', 'E540:') + call assert_fails('set tabline=%{%}', 'E539:') + call assert_fails('set tabline=%(', 'E542:') + call assert_fails('set tabline=%)', 'E542:') if has('cursorshape') " This invalid value for 'guicursor' used to cause Vim to crash. diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index 29722ef09b..e43db4d692 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -5049,7 +5049,7 @@ func Test_quickfix_window_fails_to_open() call delete('XquickfixFails') endfunc -" Test for updating the quickfix buffer whenever the assocaited quickfix list +" Test for updating the quickfix buffer whenever the associated quickfix list " is changed. func Xqfbuf_update(cchar) call s:setup_commands(a:cchar) diff --git a/src/nvim/testdir/test_regexp_latin.vim b/src/nvim/testdir/test_regexp_latin.vim index 13e44b090f..45e60a6d44 100644 --- a/src/nvim/testdir/test_regexp_latin.vim +++ b/src/nvim/testdir/test_regexp_latin.vim @@ -686,7 +686,7 @@ func Test_matchstr_with_ze() bwipe! endfunc -" Check a pattern with a look beind crossing a line boundary +" Check a pattern with a look behind crossing a line boundary func Test_lookbehind_across_line() new call append(0, ['Behind:', 'asdfasd<yyy', 'xxstart1', 'asdfasd<yy', diff --git a/src/nvim/testdir/test_sort.vim b/src/nvim/testdir/test_sort.vim index 5d7dd7bfff..540c73a772 100644 --- a/src/nvim/testdir/test_sort.vim +++ b/src/nvim/testdir/test_sort.vim @@ -1356,7 +1356,7 @@ func Test_sort_cmd() endif endfor - " Needs atleast two lines for this test + " Needs at least two lines for this test call setline(1, ['line1', 'line2']) call assert_fails('sort no', 'E474:') call assert_fails('sort c', 'E475:') diff --git a/src/nvim/testdir/test_statusline.vim b/src/nvim/testdir/test_statusline.vim index fad13e3340..492d09c645 100644 --- a/src/nvim/testdir/test_statusline.vim +++ b/src/nvim/testdir/test_statusline.vim @@ -523,4 +523,16 @@ func Test_statusline_mbyte_fillchar() %bw! endfunc +" Used to write beyond allocated memory. This assumes MAXPATHL is 4096 bytes. +func Test_statusline_verylong_filename() + let fname = repeat('x', 4090) + " Nvim's swap file creation fails on Windows (E303) due to fname's length + " exe "new " .. fname + exe "noswapfile new " .. fname + set buftype=help + set previewwindow + redraw + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_syntax.vim b/src/nvim/testdir/test_syntax.vim index b047b53b6f..6bef61ae8f 100644 --- a/src/nvim/testdir/test_syntax.vim +++ b/src/nvim/testdir/test_syntax.vim @@ -794,5 +794,18 @@ func Test_syn_include_contains_TOP() bw! endfunc +" This was using freed memory +func Test_WinEnter_synstack_synID() + autocmd WinEnter * call synstack(line("."), col(".")) + autocmd WinEnter * call synID(line('.'), col('.') - 1, 1) + call setline(1, 'aaaaa') + normal! $ + new + close + + au! WinEnter + bw! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_trycatch.vim b/src/nvim/testdir/test_trycatch.vim index adc1745b39..205ed095ea 100644 --- a/src/nvim/testdir/test_trycatch.vim +++ b/src/nvim/testdir/test_trycatch.vim @@ -1996,5 +1996,97 @@ func Test_reload_in_try_catch() call delete('Xreload') endfunc +" Test for using throw in a called function with following error {{{1 +func Test_user_command_throw_in_function_call() + let lines =<< trim END + function s:get_dict() abort + throw 'my_error' + endfunction + + try + call s:get_dict().foo() + catch /my_error/ + let caught = 'yes' + catch + let caught = v:exception + endtry + call assert_equal('yes', caught) + END + call writefile(lines, 'XtestThrow') + source XtestThrow + + call delete('XtestThrow') + unlet g:caught +endfunc + +" Test for using throw in a called function with following endtry {{{1 +func Test_user_command_function_call_with_endtry() + let lines =<< trim END + funct s:throw(msg) abort + throw a:msg + endfunc + func s:main() abort + try + try + throw 'err1' + catch + call s:throw('err2') | endtry + catch + let s:caught = 'yes' + endtry + endfunc + + call s:main() + call assert_equal('yes', s:caught) + END + call writefile(lines, 'XtestThrow') + source XtestThrow + + call delete('XtestThrow') +endfunc + +func ThisWillFail() + +endfunc + +" This was crashing prior to the fix in 8.2.3478. +func Test_error_in_catch_and_finally() + let lines =<< trim END + try + echo x + catch + for l in [] + finally + END + call writefile(lines, 'XtestCatchAndFinally') + try + source XtestCatchAndFinally + catch /E600:/ + endtry + + call delete('XtestCatchAndFinally') +endfunc + +" This was causing an illegal memory access +func Test_leave_block_in_endtry_not_called() + let lines =<< trim END + " vim9script + " try # + try " + for x in [] + if + endwhile + if + endtry + END + call writefile(lines, 'XtestEndtry') + try + source XtestEndtry + catch /E171:/ + endtry + + call delete('XtestEndtry') +endfunc + " Modeline {{{1 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua index 3f96efd4ef..e298eb3582 100644 --- a/test/functional/api/extmark_spec.lua +++ b/test/functional/api/extmark_spec.lua @@ -924,7 +924,7 @@ describe('API/extmarks', function() eq(3, set_extmark(ns, 3, positions[2][1], positions[2][2])) eq(4, set_extmark(ns, 0, positions[1][1], positions[1][2])) - -- mixing manual and allocated id:s are not recommened, but it should + -- mixing manual and allocated id:s are not recommended, but it should -- do something reasonable eq(6, set_extmark(ns, 6, positions[2][1], positions[2][2])) eq(7, set_extmark(ns, 0, positions[1][1], positions[1][2])) diff --git a/test/functional/api/highlight_spec.lua b/test/functional/api/highlight_spec.lua index 06cdb0bc19..a2f8353868 100644 --- a/test/functional/api/highlight_spec.lua +++ b/test/functional/api/highlight_spec.lua @@ -251,7 +251,7 @@ describe("API: set highlight", function() eq(highlight2_result, meths.get_hl_by_name('Test_hl', false)) end) - it ("can set emtpy cterm attr", function() + it ("can set empty cterm attr", function() local ns = get_ns() meths.set_hl(ns, 'Test_hl', { cterm = {} }) eq({}, meths.get_hl_by_name('Test_hl', false)) diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index e6ed0f939b..04b79a7157 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -1085,6 +1085,12 @@ describe('API', function() eq('aabbccdd', funcs.getcmdline()) expect('') end) + it('mappings are disabled in Cmdline mode', function() + command('cnoremap a b') + feed(':') + nvim('paste', 'a', true, -1) + eq('a', funcs.getcmdline()) + end) it('pasting with empty last chunk in Cmdline mode', function() local screen = Screen.new(20, 4) screen:attach() diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua index a0df3b7767..94a50b9a41 100644 --- a/test/functional/core/job_spec.lua +++ b/test/functional/core/job_spec.lua @@ -1038,7 +1038,7 @@ describe('jobs', function() local other_jobid = eval("jobstart(['cat', '-'], g:job_opts)") local other_pid = eval('jobpid(' .. other_jobid .. ')') - -- Other job doesn't block first job from recieving SIGHUP on jobclose() + -- Other job doesn't block first job from receiving SIGHUP on jobclose() command('call jobclose(j)') -- Have to wait so that the SIGHUP can be processed by tty-test on time. -- Can't wait for the next message in case this test fails, if it fails diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua index 3da7f6ffde..20ea3621f0 100644 --- a/test/functional/core/startup_spec.lua +++ b/test/functional/core/startup_spec.lua @@ -358,7 +358,7 @@ describe('startup', function() end) it("handles :packadd during startup", function() - -- control group: opt/bonus is not availabe by default + -- control group: opt/bonus is not available by default pack_clear [[ try let g:x = bonus#secret() diff --git a/test/functional/ex_cmds/cd_spec.lua b/test/functional/ex_cmds/cd_spec.lua index f9cce0deb6..42a811f5da 100644 --- a/test/functional/ex_cmds/cd_spec.lua +++ b/test/functional/ex_cmds/cd_spec.lua @@ -173,7 +173,7 @@ for _, cmd in ipairs {'cd', 'chdir'} do -- Change tab-local working directory and verify it is different command('silent t' .. cmd .. ' ' .. directories.tab) eq(globalDir .. pathsep .. directories.tab, cwd()) - eq(cwd(), tcwd()) -- working directory maches tab directory + eq(cwd(), tcwd()) -- working directory matches tab directory eq(1, tlwd()) eq(cwd(), wcwd()) -- still no window-directory eq(0, wlwd()) diff --git a/test/functional/ex_cmds/quickfix_commands_spec.lua b/test/functional/ex_cmds/quickfix_commands_spec.lua index c956a2df2d..94b7fa1a84 100644 --- a/test/functional/ex_cmds/quickfix_commands_spec.lua +++ b/test/functional/ex_cmds/quickfix_commands_spec.lua @@ -109,4 +109,17 @@ describe('quickfix', function() ]]) eq({0, 6, 1, 0, 1}, funcs.getcurpos()) end) + + it('BufAdd does not cause E16 when reusing quickfix buffer #18135', function() + local file = file_base .. '_reuse_qfbuf_BufAdd' + write_file(file, ('\n'):rep(100) .. 'foo') + source([[ + set grepprg=internal + autocmd BufAdd * call and(0, 0) + autocmd QuickFixCmdPost grep ++nested cclose | cwindow + ]]) + command('grep foo ' .. file) + command('grep foo ' .. file) + os.remove(file) + end) end) diff --git a/test/functional/fixtures/api_level_9.mpack b/test/functional/fixtures/api_level_9.mpack Binary files differnew file mode 100644 index 0000000000..650d7a6a4d --- /dev/null +++ b/test/functional/fixtures/api_level_9.mpack diff --git a/test/functional/fixtures/fake-lsp-server.lua b/test/functional/fixtures/fake-lsp-server.lua index 5c0de50731..7ff3713d41 100644 --- a/test/functional/fixtures/fake-lsp-server.lua +++ b/test/functional/fixtures/fake-lsp-server.lua @@ -119,8 +119,10 @@ function tests.check_workspace_configuration() notify('workspace/configuration', { items = { { section = "testSetting1" }; { section = "testSetting2" }; + { section = "test.Setting3" }; + { section = "test.Setting4" }; } }) - expect_notification('workspace/configuration', { true; vim.NIL}) + expect_notification('workspace/configuration', { true; false; 'nested'; vim.NIL}) notify('shutdown') end; } diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua index 6cda9af0f4..436b431e38 100644 --- a/test/functional/plugin/lsp_spec.lua +++ b/test/functional/plugin/lsp_spec.lua @@ -347,6 +347,8 @@ describe('LSP', function() {NIL, { items = { { section = "testSetting1" }; { section = "testSetting2" }; + { section = "test.Setting3" }; + { section = "test.Setting4" }; }}, { method="workspace/configuration", client_id=1}}; {NIL, {}, {method="start", client_id=1}}; } @@ -368,6 +370,7 @@ describe('LSP', function() client.config.settings = { testSetting1 = true; testSetting2 = false; + test = {Setting3 = 'nested' }; }]=]) end if ctx.method == 'workspace/configuration' then diff --git a/test/functional/terminal/highlight_spec.lua b/test/functional/terminal/highlight_spec.lua index ab4b4e9147..32c911a5e8 100644 --- a/test/functional/terminal/highlight_spec.lua +++ b/test/functional/terminal/highlight_spec.lua @@ -215,7 +215,7 @@ describe(':terminal highlight with custom palette', function() clear() screen = Screen.new(50, 7) screen:set_default_attr_ids({ - [1] = {foreground = tonumber('0x123456')}, -- no fg_indexed when overriden + [1] = {foreground = tonumber('0x123456')}, -- no fg_indexed when overridden [2] = {foreground = 12}, [3] = {bold = true, reverse = true}, [5] = {background = 11}, diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 74eb5d5b8e..4982506631 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -728,7 +728,7 @@ end]] ]]} end) - it('can have virtual text which combines foreground and backround groups', function() + it('can have virtual text which combines foreground and background groups', function() screen:set_default_attr_ids { [1] = {bold=true, foreground=Screen.colors.Blue}; [2] = {background = tonumber('0x123456'), foreground = tonumber('0xbbbbbb')}; diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index 949591870a..abb0948c60 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -1013,7 +1013,7 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim end) it('redraws NOT_VALID correctly after message', function() - -- edge case: only one window was set NOT_VALID. Orginal report + -- edge case: only one window was set NOT_VALID. Original report -- used :make, but fake it using one command to set the current -- window NOT_VALID and another to show a long message. command("set more") @@ -1227,7 +1227,7 @@ describe('ui/msg_puts_printf', function() pending('Locale ja_JP.UTF-8 not supported', function() end) return elseif helpers.isCI() then - -- Fails non--Windows CI. Message catalog direcotry issue? + -- Fails non--Windows CI. Message catalog directory issue? pending('fails on unix CI', function() end) return end diff --git a/test/functional/ui/multibyte_spec.lua b/test/functional/ui/multibyte_spec.lua index e6a79feadc..c3c79ea574 100644 --- a/test/functional/ui/multibyte_spec.lua +++ b/test/functional/ui/multibyte_spec.lua @@ -26,7 +26,7 @@ describe("multibyte rendering", function() ̊ x]]) feed("gg") - -- verify the modifier infact is alone + -- verify the modifier in fact is alone feed_command("ascii") screen:expect([[ ^ ̊ | diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua index 07c6c5b046..067d3eef4a 100644 --- a/test/functional/ui/popupmenu_spec.lua +++ b/test/functional/ui/popupmenu_spec.lua @@ -1952,7 +1952,7 @@ describe('builtin popupmenu', function() ]]) end) - it('wildoptions=pum with scrolled mesages ', function() + it('wildoptions=pum with scrolled messages ', function() screen:try_resize(40,10) command('set wildmenu') command('set wildoptions=pum') @@ -2191,7 +2191,7 @@ describe('builtin popupmenu', function() {20:-- Keyword Local completion (^N^P) }{21:match 1 of 65} | ]]) - -- can disable blending for indiviual attribute. For instance current + -- can disable blending for individual attribute. For instance current -- selected item. (also tests that `hi Pmenu*` take immediate effect) command('hi PMenuSel blend=0') screen:expect([[ diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index 3e94fdbf44..e8a39ab6f8 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -544,7 +544,7 @@ function Screen:_wait(check, flags) elseif not checked then err = check() if not err and flags.unchanged then - -- expecting NO screen change: use a shorter timout + -- expecting NO screen change: use a shorter timeout success_seen = true end end diff --git a/test/functional/ui/searchhl_spec.lua b/test/functional/ui/searchhl_spec.lua index 5540b3c2dc..2e60930127 100644 --- a/test/functional/ui/searchhl_spec.lua +++ b/test/functional/ui/searchhl_spec.lua @@ -471,7 +471,7 @@ describe('search highlighting', function() {4:search hit BOTTOM, continuing at TOP} | ]]) - -- check hilights work also in folds + -- check highlights work also in folds feed("zf4j") command("%foldopen") screen:expect([[ diff --git a/test/functional/vimscript/system_spec.lua b/test/functional/vimscript/system_spec.lua index 24a1f05390..bedf7e5498 100644 --- a/test/functional/vimscript/system_spec.lua +++ b/test/functional/vimscript/system_spec.lua @@ -527,7 +527,7 @@ describe('systemlist()', function() end) -- Unlike `system()` which uses SOH to represent NULs, with `systemlist()` - -- input and ouput are the same. + -- input and output are the same. describe('with linefeed characters inside list items', function() it('converts linefeed characters to NULs', function() eq({'l1\np2', 'line2\na\nb', 'l3'}, |