From b70224e3bd89f7eb56911d94008eb79bf29e6c67 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 25 Apr 2026 11:16:18 -0400 Subject: [PATCH] docs: misc #39256 --- .github/workflows/labeler_issue.yml | 17 ++++++--- runtime/doc/dev.txt | 4 +-- runtime/doc/dev_arch.txt | 12 +++++++ runtime/doc/dev_vimpatch.txt | 5 ++- runtime/doc/lua.txt | 9 +++++ runtime/doc/news.txt | 2 ++ runtime/doc/options.txt | 23 +++++++++---- runtime/doc/vim_diff.txt | 2 +- runtime/doc/vimfn.txt | 23 +++++++------ runtime/lua/vim/_core/defaults.lua | 6 ++-- runtime/lua/vim/_meta.lua | 2 ++ runtime/lua/vim/_meta/options.gen.lua | 24 ++++++++++--- runtime/lua/vim/_meta/vimfn.gen.lua | 23 +++++++------ runtime/lua/vim/fs.lua | 9 +++++ src/gen/lint.lua | 2 ++ src/nvim/api/autocmd.c | 2 -- src/nvim/eval.lua | 23 +++++++------ src/nvim/eval/fs.c | 8 +++-- src/nvim/options.lua | 25 ++++++++++---- src/nvim/os/env.c | 2 +- test/functional/options/defaults_spec.lua | 5 +++ test/functional/terminal/tui_spec.lua | 2 +- test/functional/ui/title_spec.lua | 42 ++++++++++------------- 23 files changed, 183 insertions(+), 89 deletions(-) diff --git a/.github/workflows/labeler_issue.yml b/.github/workflows/labeler_issue.yml index 1b83b2ed26..e448c604e9 100644 --- a/.github/workflows/labeler_issue.yml +++ b/.github/workflows/labeler_issue.yml @@ -17,18 +17,25 @@ jobs: script: | const title = context.payload.issue.title; const titleSplit = title.split(/\b/).map(e => e.toLowerCase()); - const keywords = ['api', 'treesitter', 'ui', 'ui2', 'lsp']; - var match = new Set(); + const keywords = ['api', 'lsp', 'treesitter', 'ui', 'ui2']; + var labels = new Set(); + for (const keyword of keywords) { if (titleSplit.includes(keyword)) { - match.add(keyword) + labels.add(keyword) } } - if (match.size !== 0) { + + // Special cases. + if (titleSplit.includes('vim.pack')) { + labels.add('packages') + } + + if (labels.size !== 0) { github.rest.issues.addLabels({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, - labels: Array.from(match) + labels: Array.from(labels) }) } diff --git a/runtime/doc/dev.txt b/runtime/doc/dev.txt index 19162f2587..e5ea15ae0a 100644 --- a/runtime/doc/dev.txt +++ b/runtime/doc/dev.txt @@ -306,8 +306,8 @@ To choose a new "EXX" error code (e.g. |E5555|), just print a message with a new EXX number: > emsg(_("E996: Invalid thing")); < -To see existing error codes: > - :new | put =filter(getcompletion('h E', 'cmdline'), 'v:val =~# ''E\d\d''') +To see existing error codes: >vim + :exe 'help' | let g:errtags=sort(map(taglist('E\d\d\d\?\d\?'), 'v:val.name'), 'N') | new | put =g:errtags The `linterrcodes` build target checks that all "EXX" codes are unique and have help tags. It runs in CI, but you can also run it locally: > diff --git a/runtime/doc/dev_arch.txt b/runtime/doc/dev_arch.txt index e94cbcd450..1ced08f361 100644 --- a/runtime/doc/dev_arch.txt +++ b/runtime/doc/dev_arch.txt @@ -169,6 +169,18 @@ Other references: - https://github.com/neovim/neovim/pull/18375 - https://github.com/neovim/neovim/pull/21605 +============================================================================== +Filesystem *dev-filesystem* + +https://github.com/neovim/neovim/issues/36112 Path handling, especially +separator chars ("/" vs "\"), is designed as follows: "/" separators are used +every except at the "edges", i.e. the separator chars are coverted +just-in-time, and only when absolutely needed. This is similar to how UTF-8 +encoding is used internally for all text, but buffers can read/write various +encodings. + +P.S. Windows handles "/" separators just fine, except in rare cases. It'll be +fine, don't worry. Just use "/", for god's sake! ============================================================================== API diff --git a/runtime/doc/dev_vimpatch.txt b/runtime/doc/dev_vimpatch.txt index 8d0b4cb881..f6b7cffe69 100644 --- a/runtime/doc/dev_vimpatch.txt +++ b/runtime/doc/dev_vimpatch.txt @@ -99,6 +99,9 @@ https://github.com/neovim/neovim/commit/00f60c2ce78fc1280e93d5a36bc7b2267d5f4ac6 TYPES OF "NOT APPLICABLE" VIM PATCHES ~ +- Unwanted features: + - "modelinestrict" https://github.com/neovim/neovim/issues/38985 + - "tabpanel" - Vim9script features, and anything related to `:scriptversion`. (Nvim supports Vimscript version 1 only.) Be aware that patches labelled `Vim9:` may still contain applicable fixes to other parts of the codebase, so these @@ -352,4 +355,4 @@ Pattern matching has several differences: When modifying an existing regular pattern, make sure that it still fits its group. -vim:tw=78:ts=8:noet:ft=help:norl: +vim:tw=78:ts=8:et:ft=help:norl: diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index 3c292e5e5f..c508410de3 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -2508,6 +2508,15 @@ Example: >lua vim.print(vim.fn.readblob('.git/config')) < + *vim.fs.write()* + +You can use |writefile()| to write a file without explicitly opening/closing +it. + +Example: >lua + vim.fn.writefile('foo\0bar', 'data.bin', 'b') +< + vim.fs.abspath({path}) *vim.fs.abspath()* Converts `path` to an absolute path. Expands tilde (~) at the beginning of diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index 6eaa69cb64..ac7c08693a 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -157,6 +157,8 @@ LSP LUA • |vim.net.request()| can specify custom headers by passing `opts.headers`. +• |writefile()| treats Lua strings as "blob", so it can be used to write + binary data. • |vim.filetype.inspect()| returns a copy of the internal tables used for filetype detection. • Added `__eq` metamethod to |vim.VersionRange|. 2 distinct but representing diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index a106b6065e..6000dc92f1 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -5298,6 +5298,10 @@ A jump table for the options with a short description can be found at |Q_op|. For a window-local value, -1 means to use the global value. Values below -1 are invalid. + Example: >vim + :set scrolloff=99 scrolloffpad=1 +< + After using the local value, go back the global value with one of these two: >vim setlocal scrolloffpad< @@ -7010,15 +7014,22 @@ A jump table for the options with a short description can be found at |Q_op|. used for CTRL-\ CTRL-N and CTRL-\ CTRL-G when part of a command has been typed. - *'ttyfast'* *'tf'* *'nottyfast'* *'notf'* + *'ttyfast'* *'tf'* *'nottyfast'* *'notf'* *E1568* *$NVIM_NOTTYFAST* 'ttyfast' 'tf' boolean (default on) global - Assume that the underlying terminal can respond quickly to queries - required by features such as 'background' detection. + Enables Nvim |TUI| features which assume a fast (usually local) host + terminal. During startup, Nvim queries the terminal (for 'background' + detection, etc.) and must wait for a response (or timeout). - Nvim issues terminal queries before reading the user's |config| file, - so disabling this option there will not work. Set $NVIM_NOTTYFAST - before starting Nvim to disable terminal queries. + If your terminal environment is slow (e.g. remote SSH), or broken + (doesn't respond to queries), Nvim startup may be slower. Therefore + you can disable this option by setting the `$NVIM_NOTTYFAST` + environment variable before starting Nvim: > + NVIM_NOTTYFAST=1 nvim +< + + The queries are performed early, before |--cmd| and user |config|, so + `:set nottyfast` in your config happens too late. *'undodir'* *'udir'* *E5003* 'undodir' 'udir' string (default "$XDG_STATE_HOME/nvim/undo//") diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 1d3e61b54a..06351529f5 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -90,7 +90,7 @@ Defaults *defaults* *nvim-defaults* - 'ttimeoutlen' defaults to 50 - 'ttyfast' is set by default, but it can be unset during startup by setting the environment variable `NVIM_NOTTYFAST` to adjust the startup sequence for - slow environments. + slow environments (such as ssh). - 'undodir' defaults to ~/.local/state/nvim/undo// (|xdg|), auto-created - 'viewoptions' includes "unix,slash", excludes "options" - 'viminfo' includes "!" diff --git a/runtime/doc/vimfn.txt b/runtime/doc/vimfn.txt index 04830089d4..1ec9374d17 100644 --- a/runtime/doc/vimfn.txt +++ b/runtime/doc/vimfn.txt @@ -12398,16 +12398,19 @@ wordcount() *wordcount()* Return: ~ (`any`) -writefile({object}, {fname} [, {flags}]) *writefile()* - When {object} is a |List| write it to file {fname}. Each list - item is separated with a NL. Each list item must be a String - or Number. - All NL characters are replaced with a NUL character. - Inserting CR characters needs to be done before passing {list} - to writefile(). +writefile({data}, {fname} [, {flags}]) *writefile()* + Writes {data} to file {fname}. - When {object} is a |Blob| write the bytes to file {fname} - unmodified, also when binary mode is not specified. + - When {data} is a |Blob| its bytes are written unmodified + (even if binary mode "b" is not specified). + - When {data} is a Lua string, it is treated as a blob. + - When {data} is a |List|, each list item is treated as a text + line (terminated with a newline). Each list item must be + a String or Number. + - Any NL (newline) chars in the line are treated as a NUL + character. (This is a workaround to allow Vimscript to + write binary data, and is irrelevant for Lua, which should + just pass a string instead.) {flags} must be a String. These characters are recognized: @@ -12446,7 +12449,7 @@ writefile({object}, {fname} [, {flags}]) *writefile()* < Parameters: ~ - • {object} (`any`) + • {data} (`any`) • {fname} (`string`) • {flags} (`string?`) diff --git a/runtime/lua/vim/_core/defaults.lua b/runtime/lua/vim/_core/defaults.lua index 40c2304a1a..4dfe0cd057 100644 --- a/runtime/lua/vim/_core/defaults.lua +++ b/runtime/lua/vim/_core/defaults.lua @@ -468,11 +468,11 @@ do vim.keymap.set({ 'x' }, '[N', function() require 'vim.treesitter._select'.select_grow_prev(vim.v.count1) - end, { desc = 'Select expand previous node' }) + end, { desc = 'Select previous sibling node' }) vim.keymap.set({ 'x' }, ']N', function() require 'vim.treesitter._select'.select_grow_next(vim.v.count1) - end, { desc = 'Select expand next node' }) + end, { desc = 'Select next sibling node' }) vim.keymap.set({ 'x', 'o' }, 'an', function() if vim.treesitter.get_parser(nil, nil, { error = false }) then @@ -1002,7 +1002,7 @@ do and os.getenv('NVIM_TEST') == nil then vim.notify( - "defaults.lua: Did not detect DSR response from terminal for 'background' detection. This results in a slower startup time. To disable this and other 'ttyfast' features during startup, set the environment variable NVIM_NOTTYFAST", + "E1568: Terminal did not respond to DSR request for 'background' color. Startup may be slower. :help 'ttyfast'", vim.log.levels.WARN, { _truncate = true } ) diff --git a/runtime/lua/vim/_meta.lua b/runtime/lua/vim/_meta.lua index 9ac6ceeb77..3c8947751d 100644 --- a/runtime/lua/vim/_meta.lua +++ b/runtime/lua/vim/_meta.lua @@ -1,4 +1,6 @@ --- @meta +-- This file is NOT generated, edit it directly. +error('Cannot require a meta file') --- @alias elem_or_list T|T[] diff --git a/runtime/lua/vim/_meta/options.gen.lua b/runtime/lua/vim/_meta/options.gen.lua index 724432cddb..5f68f31e82 100644 --- a/runtime/lua/vim/_meta/options.gen.lua +++ b/runtime/lua/vim/_meta/options.gen.lua @@ -5516,6 +5516,12 @@ vim.go.so = vim.go.scrolloff --- For a window-local value, -1 means to use the global value. --- Values below -1 are invalid. --- +--- Example: +--- +--- ```vim +--- :set scrolloff=99 scrolloffpad=1 +--- ``` +--- --- After using the local value, go back the global value with one of --- these two: --- @@ -7555,12 +7561,20 @@ vim.o.ttm = vim.o.ttimeoutlen vim.go.ttimeoutlen = vim.o.ttimeoutlen vim.go.ttm = vim.go.ttimeoutlen ---- Assume that the underlying terminal can respond quickly to queries ---- required by features such as 'background' detection. +--- Enables Nvim `TUI` features which assume a fast (usually local) host +--- terminal. During startup, Nvim queries the terminal (for 'background' +--- detection, etc.) and must wait for a response (or timeout). --- ---- Nvim issues terminal queries before reading the user's `config` file, ---- so disabling this option there will not work. Set $NVIM_NOTTYFAST ---- before starting Nvim to disable terminal queries. +--- If your terminal environment is slow (e.g. remote SSH), or broken +--- (doesn't respond to queries), Nvim startup may be slower. Therefore +--- you can disable this option by setting the `$NVIM_NOTTYFAST` +--- environment variable before starting Nvim: +--- ``` +--- NVIM_NOTTYFAST=1 nvim +--- ``` +--- +--- The queries are performed early, before `--cmd` and user `config`, so +--- `:set nottyfast` in your config happens too late. --- --- @type boolean vim.o.ttyfast = true diff --git a/runtime/lua/vim/_meta/vimfn.gen.lua b/runtime/lua/vim/_meta/vimfn.gen.lua index 8d6053e71e..19f55259e7 100644 --- a/runtime/lua/vim/_meta/vimfn.gen.lua +++ b/runtime/lua/vim/_meta/vimfn.gen.lua @@ -11273,15 +11273,18 @@ function vim.fn.winwidth(nr) end --- @return any function vim.fn.wordcount() end ---- When {object} is a |List| write it to file {fname}. Each list ---- item is separated with a NL. Each list item must be a String ---- or Number. ---- All NL characters are replaced with a NUL character. ---- Inserting CR characters needs to be done before passing {list} ---- to writefile(). +--- Writes {data} to file {fname}. --- ---- When {object} is a |Blob| write the bytes to file {fname} ---- unmodified, also when binary mode is not specified. +--- - When {data} is a |Blob| its bytes are written unmodified +--- (even if binary mode "b" is not specified). +--- - When {data} is a Lua string, it is treated as a blob. +--- - When {data} is a |List|, each list item is treated as a text +--- line (terminated with a newline). Each list item must be +--- a String or Number. +--- - Any NL (newline) chars in the line are treated as a NUL +--- character. (This is a workaround to allow Vimscript to +--- write binary data, and is irrelevant for Lua, which should +--- just pass a string instead.) --- --- {flags} must be a String. These characters are recognized: --- @@ -11319,11 +11322,11 @@ function vim.fn.wordcount() end --- call writefile(fl, "foocopy", "b") --- < --- ---- @param object any +--- @param data any --- @param fname string --- @param flags? string --- @return any -function vim.fn.writefile(object, fname, flags) end +function vim.fn.writefile(data, fname, flags) end --- Bitwise XOR on the two arguments. The arguments are converted --- to a number. A List, Dict or Float argument causes an error. diff --git a/runtime/lua/vim/fs.lua b/runtime/lua/vim/fs.lua index 13162d5b19..bfb767f9c2 100644 --- a/runtime/lua/vim/fs.lua +++ b/runtime/lua/vim/fs.lua @@ -30,6 +30,15 @@ --- ```lua --- vim.print(vim.fn.readblob('.git/config')) --- ``` +--- +--- [vim.fs.write()]() +--- +--- You can use |writefile()| to write a file without explicitly opening/closing it. +--- +--- Example: +--- ```lua +--- vim.fn.writefile('foo\0bar', 'data.bin', 'b') +--- ``` local uv = vim.uv diff --git a/src/gen/lint.lua b/src/gen/lint.lua index 3df3ab6350..fd8292f29d 100644 --- a/src/gen/lint.lua +++ b/src/gen/lint.lua @@ -22,8 +22,10 @@ local banned_verbs = { delete = 'del', disable = 'enable', exit = 'cancel', -- or "stop" + -- format = 'fmt', list = 'get', notify = 'print', -- or "echo" + pretty = 'fmt', remove = 'del', toggle = 'enable', } diff --git a/src/nvim/api/autocmd.c b/src/nvim/api/autocmd.c index c846b33cef..43dbbb4cb0 100644 --- a/src/nvim/api/autocmd.c +++ b/src/nvim/api/autocmd.c @@ -692,9 +692,7 @@ void nvim_exec_autocmds(Object event, Dict(exec_autocmds) *opts, Arena *arena, E { int au_group = AUGROUP_ALL; bool modeline = true; - buf_T *b = curbuf; - Object *data = NULL; Array event_array = unpack_string_or_array(event, "event", true, arena, err); diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 0927a29a29..f8cf01f8a3 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -13659,15 +13659,18 @@ M.funcs = { args = { 2, 3 }, base = 1, desc = [=[ - When {object} is a |List| write it to file {fname}. Each list - item is separated with a NL. Each list item must be a String - or Number. - All NL characters are replaced with a NUL character. - Inserting CR characters needs to be done before passing {list} - to writefile(). + Writes {data} to file {fname}. - When {object} is a |Blob| write the bytes to file {fname} - unmodified, also when binary mode is not specified. + - When {data} is a |Blob| its bytes are written unmodified + (even if binary mode "b" is not specified). + - When {data} is a Lua string, it is treated as a blob. + - When {data} is a |List|, each list item is treated as a text + line (terminated with a newline). Each list item must be + a String or Number. + - Any NL (newline) chars in the line are treated as a NUL + character. (This is a workaround to allow Vimscript to + write binary data, and is irrelevant for Lua, which should + just pass a string instead.) {flags} must be a String. These characters are recognized: @@ -13707,8 +13710,8 @@ M.funcs = { ]=], name = 'writefile', - params = { { 'object', 'any' }, { 'fname', 'string' }, { 'flags', 'string' } }, - signature = 'writefile({object}, {fname} [, {flags}])', + params = { { 'data', 'any' }, { 'fname', 'string' }, { 'flags', 'string' } }, + signature = 'writefile({data}, {fname} [, {flags}])', }, xor = { args = 2, diff --git a/src/nvim/eval/fs.c b/src/nvim/eval/fs.c index abec37c9c8..c5e0898ef8 100644 --- a/src/nvim/eval/fs.c +++ b/src/nvim/eval/fs.c @@ -1753,6 +1753,10 @@ void f_writefile(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) return; } + // XXX: this logic is bit weird because of how `decode_string` works: #39328 + // - if decode_string finds NUL in the Lua string, it assigns VAR_BLOB + // - else it assigns VAR_STRING + if (argvars[0].v_type == VAR_LIST) { TV_LIST_ITER_CONST(argvars[0].vval.v_list, li, { if (!tv_check_str_or_nr(TV_LIST_ITEM_TV(li))) { @@ -1760,9 +1764,9 @@ void f_writefile(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) } }); } else if (argvars[0].v_type != VAR_BLOB + // Always treat Lua strings as "blob" data. && !(argvars[0].v_type == VAR_STRING && script_is_lua(current_sctx.sc_sid))) { - semsg(_(e_invarg2), - _("writefile() first argument must be a List or a Blob")); + semsg(_(e_invarg2), _("writefile() first argument must be a List or a Blob")); return; } diff --git a/src/nvim/options.lua b/src/nvim/options.lua index 9192a1ee51..29115b5716 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -7264,6 +7264,10 @@ local options = { For a window-local value, -1 means to use the global value. Values below -1 are invalid. + Example: >vim + :set scrolloff=99 scrolloffpad=1 + < + After using the local value, go back the global value with one of these two: >vim setlocal scrolloffpad< @@ -9778,17 +9782,26 @@ local options = { abbreviation = 'tf', defaults = true, desc = [=[ - Assume that the underlying terminal can respond quickly to queries - required by features such as 'background' detection. - - Nvim issues terminal queries before reading the user's |config| file, - so disabling this option there will not work. Set $NVIM_NOTTYFAST - before starting Nvim to disable terminal queries. + Enables Nvim |TUI| features which assume a fast (usually local) host + terminal. During startup, Nvim queries the terminal (for 'background' + detection, etc.) and must wait for a response (or timeout). + + If your terminal environment is slow (e.g. remote SSH), or broken + (doesn't respond to queries), Nvim startup may be slower. Therefore + you can disable this option by setting the `$NVIM_NOTTYFAST` + environment variable before starting Nvim: > + NVIM_NOTTYFAST=1 nvim + < + + The queries are performed early, before |--cmd| and user |config|, so + `:set nottyfast` in your config happens too late. ]=], full_name = 'ttyfast', no_mkrc = true, scope = { 'global' }, short_desc = N_('assume terminal responds quickly, enabling more features'), + -- Vim E1568: https://github.com/vim/vim/blob/0f9218851dc91a855c3d186ccd05f550907cf37e/src/errors.h#L3791 + tags = { 'E1568', '$NVIM_NOTTYFAST' }, type = 'boolean', varname = 'p_tf', }, diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index 8e21a8c7db..37460fe1c5 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -194,7 +194,7 @@ int os_setenv(const char *name, const char *value, int overwrite) #endif int r; #ifdef MSWIN - // libintl uses getenv() for LC_ALL/LANG/etc., so we must use _putenv_s(). + // Call _putenv_s() so libintl can see LC_ALL/LANG/etc. libuv only calls SetEnvironmentVariableW. if (striequal(name, "LC_ALL") || striequal(name, "LANGUAGE") || striequal(name, "LANG") || striequal(name, "LC_MESSAGES")) { r = _putenv_s(name, value); // NOLINT diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua index f87cfa747d..f1b42430a9 100644 --- a/test/functional/options/defaults_spec.lua +++ b/test/functional/options/defaults_spec.lua @@ -30,6 +30,11 @@ local is_os = t.is_os local testlog = 'Xtest-defaults-log' describe('startup defaults', function() + it("NVIM_NOTTYFAST=1 unsets 'ttyfast'", function() + clear { env = { NVIM_NOTTYFAST = '1' } } + eq(0, n.eval('&ttyfast')) + end) + describe(':filetype', function() local function expect_filetype(expected) local screen = Screen.new(50, 4) diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua index 77660d8b23..ce91534304 100644 --- a/test/functional/terminal/tui_spec.lua +++ b/test/functional/terminal/tui_spec.lua @@ -3326,7 +3326,7 @@ describe('TUI', function() end) local child_session = n.connect(child_server) local expected_msg = - "defaults.lua: Did not detect DSR response from terminal for 'background' detection. This results in a slower startup time. To disable this and other 'ttyfast' features during startup, set the environment variable NVIM_NOTTYFAST" + "E1568: Terminal did not respond to DSR request for 'background' color. Startup may be slower. :help 'ttyfast'" retry(nil, 4000, function() eq({ true, { mode = 'n', blocking = false } }, { child_session:request('nvim_get_mode') }) if not is_os('win') then -- ConPTY provides DSR response on Windows? diff --git a/test/functional/ui/title_spec.lua b/test/functional/ui/title_spec.lua index e2a0881569..37db486abd 100644 --- a/test/functional/ui/title_spec.lua +++ b/test/functional/ui/title_spec.lua @@ -20,7 +20,7 @@ describe('title', function() screen = Screen.new() end) - it('defaults to "No Name" and the PWD in the title if the buffer is unnamed', function() + it('shows "No Name", CWD if the buffer is unnamed', function() local expected = (is_os('win') and '[No Name] (C:/) - Nvim' or '[No Name] (/) - Nvim') command(is_os('win') and 'cd C:\\' or 'cd /') command('set title') @@ -29,30 +29,24 @@ describe('title', function() end) end) - it( - 'defaults to the filename and its directory in the title if the buffer is named as a path outside the PWD', - function() - local expected = (is_os('win') and 'myfile (C:/mydir) - Nvim' or 'myfile (/mydir) - Nvim') - command('set title') - command(is_os('win') and 'file C:\\mydir\\myfile' or 'file /mydir/myfile') - screen:expect(function() - eq(expected, screen.title) - end) - end - ) + it('shows filename + directory if the buffer name is outside CWD', function() + local expected = (is_os('win') and 'myfile (C:/mydir) - Nvim' or 'myfile (/mydir) - Nvim') + command('set title') + command(is_os('win') and 'file C:\\mydir\\myfile' or 'file /mydir/myfile') + screen:expect(function() + eq(expected, screen.title) + end) + end) - it( - 'defaults to the filename and the PWD in the title if the buffer is a file in the PWD', - function() - local expected = (is_os('win') and 'myfile (C:/) - Nvim' or 'myfile (/) - Nvim') - command('set title') - command(is_os('win') and 'cd C:\\' or 'cd /') - command('file myfile') - screen:expect(function() - eq(expected, screen.title) - end) - end - ) + it('shows filename + CWD if the buffer is in CWD', function() + local expected = (is_os('win') and 'myfile (C:/) - Nvim' or 'myfile (/) - Nvim') + command('set title') + command(is_os('win') and 'cd C:\\' or 'cd /') + command('file myfile') + screen:expect(function() + eq(expected, screen.title) + end) + end) it('is updated in Insert mode', function() command(is_os('win') and 'cd C:\\' or 'cd /')