diff options
-rw-r--r-- | runtime/doc/builtin.txt | 8 | ||||
-rw-r--r-- | runtime/doc/deprecated.txt | 1 | ||||
-rw-r--r-- | runtime/doc/lua.txt | 18 | ||||
-rw-r--r-- | runtime/doc/news.txt | 3 | ||||
-rw-r--r-- | runtime/doc/options.txt | 3 | ||||
-rw-r--r-- | runtime/lua/tohtml.lua | 5 | ||||
-rw-r--r-- | runtime/lua/vim/_meta/builtin.lua | 6 | ||||
-rw-r--r-- | runtime/lua/vim/_meta/options.lua | 3 | ||||
-rw-r--r-- | runtime/lua/vim/_meta/vimfn.lua | 8 | ||||
-rw-r--r-- | runtime/lua/vim/lsp.lua | 15 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/log.lua | 26 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/protocol.lua | 60 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/rpc.lua | 9 | ||||
-rw-r--r-- | runtime/lua/vim/shared.lua | 3 | ||||
-rw-r--r-- | src/nvim/eval.lua | 8 | ||||
-rw-r--r-- | src/nvim/eval/funcs.c | 3 | ||||
-rw-r--r-- | src/nvim/fileio.c | 2 | ||||
-rw-r--r-- | src/nvim/options.lua | 3 | ||||
-rw-r--r-- | src/nvim/os/env.c | 5 | ||||
-rw-r--r-- | src/nvim/os/pty_process_win.c | 26 | ||||
-rw-r--r-- | test/functional/autocmd/focus_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/plugin/tohtml_spec.lua | 16 | ||||
-rw-r--r-- | test/old/testdir/runnvim.vim | 3 | ||||
-rw-r--r-- | test/old/testdir/test_options.vim | 38 | ||||
-rw-r--r-- | test/old/testdir/test_undo.vim | 2 |
25 files changed, 160 insertions, 116 deletions
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 87353ff5a6..c5f3946871 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -2925,7 +2925,7 @@ getregion({pos1}, {pos2} [, {opts}]) *getregion()* {pos1} and {pos2} must both be |List|s with four numbers. See |getpos()| for the format of the list. It's possible to specify positions from a different buffer, but please - note the limitations at |getregion-notes| + note the limitations at |getregion-notes|. The optional argument {opts} is a Dict and supports the following items: @@ -2959,9 +2959,9 @@ getregion({pos1}, {pos2} [, {opts}]) *getregion()* - If {pos1} and {pos2} are not in the same buffer, an empty list is returned. - {pos1} and {pos2} must belong to a |bufloaded()| buffer. - - It is evaluated in current window context, this makes a - different if a buffer is displayed in a different window and - 'virtualedit' or 'list' is set + - It is evaluated in current window context, which makes a + difference if the buffer is displayed in a window with + different 'virtualedit' or 'list' values. Examples: > :xnoremap <CR> diff --git a/runtime/doc/deprecated.txt b/runtime/doc/deprecated.txt index 9ca4e66c7b..5ac4ad4ce2 100644 --- a/runtime/doc/deprecated.txt +++ b/runtime/doc/deprecated.txt @@ -169,6 +169,7 @@ LUA - vim.register_keystroke_callback() Use |vim.on_key()| instead. - *vim.pretty_print()* Use |vim.print()| instead. - *vim.loop* Use |vim.uv| instead. +- *vim.tbl_add_reverse_lookup()* NORMAL COMMANDS - *]f* *[f* Same as "gf". diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index 4f8c685a41..03e9ca4dd9 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -922,7 +922,7 @@ vim.in_fast_event() *vim.in_fast_event()* When this is `false` most API functions are callable (but may be subject to other restrictions such as |textlock|). -vim.rpcnotify({channel}, {method}, {args}, {...}) *vim.rpcnotify()* +vim.rpcnotify({channel}, {method}, {...}) *vim.rpcnotify()* Sends {event} to {channel} via |RPC| and returns immediately. If {channel} is 0, the event is broadcast to all channels. @@ -931,10 +931,9 @@ vim.rpcnotify({channel}, {method}, {args}, {...}) *vim.rpcnotify()* Parameters: ~ • {channel} (`integer`) • {method} (`string`) - • {args} (`any[]?`) • {...} (`any?`) -vim.rpcrequest({channel}, {method}, {args}, {...}) *vim.rpcrequest()* +vim.rpcrequest({channel}, {method}, {...}) *vim.rpcrequest()* Sends a request to {channel} to invoke {method} via |RPC| and blocks until a response is received. @@ -944,7 +943,6 @@ vim.rpcrequest({channel}, {method}, {args}, {...}) *vim.rpcrequest()* Parameters: ~ • {channel} (`integer`) • {method} (`string`) - • {args} (`any[]?`) • {...} (`any?`) vim.schedule({fn}) *vim.schedule()* @@ -2149,18 +2147,6 @@ vim.startswith({s}, {prefix}) *vim.startswith()* Return: ~ (`boolean`) `true` if `prefix` is a prefix of `s` -vim.tbl_add_reverse_lookup({o}) *vim.tbl_add_reverse_lookup()* - Add the reverse lookup values to an existing table. For example: - `tbl_add_reverse_lookup { A = 1 } == { [1] = 'A', A = 1 }` - - Note that this modifies the input. - - Parameters: ~ - • {o} (`table`) Table to add the reverse to - - Return: ~ - (`table`) o - vim.tbl_contains({t}, {value}, {opts}) *vim.tbl_contains()* Checks if a table contains a given value, specified either directly or via a predicate that is checked for each value. diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index 516ff6f0fe..3029414500 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -526,4 +526,7 @@ release. populated. Background color detection is now performed in Lua by the Nvim core, not the TUI. +• vim.shared functions: + - |vim.tbl_add_reverse_lookup()| + vim:tw=78:ts=8:sw=2:et:ft=help:norl: diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 38a2a3b452..edd5149621 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -5474,7 +5474,8 @@ A jump table for the options with a short description can be found at |Q_op|. items, for instance "scanning tags" q do not show "recording @a" when recording a macro *shm-q* F don't give the file info when editing a file, like *shm-F* - `:silent` was used for the command + `:silent` was used for the command; note that this also + affects messages from 'autoread' reloading S do not show search count message when searching, e.g. *shm-S* "[1/5]" diff --git a/runtime/lua/tohtml.lua b/runtime/lua/tohtml.lua index 68fef38c64..505de720ba 100644 --- a/runtime/lua/tohtml.lua +++ b/runtime/lua/tohtml.lua @@ -575,7 +575,10 @@ local function styletable_extmarks(state) --TODO(altermo) extmarks may have col/row which is outside of the buffer, which could cause an error local bufnr = state.bufnr local extmarks = vim.api.nvim_buf_get_extmarks(bufnr, -1, 0, -1, { details = true }) - local namespaces = vim.tbl_add_reverse_lookup(vim.api.nvim_get_namespaces()) + local namespaces = {} --- @type table<integer, string> + for ns, ns_id in pairs(vim.api.nvim_get_namespaces()) do + namespaces[ns_id] = ns + end for _, v in ipairs(extmarks) do _styletable_extmarks_highlight(state, v, namespaces) end diff --git a/runtime/lua/vim/_meta/builtin.lua b/runtime/lua/vim/_meta/builtin.lua index 4831989e1a..9a67667f02 100644 --- a/runtime/lua/vim/_meta/builtin.lua +++ b/runtime/lua/vim/_meta/builtin.lua @@ -91,9 +91,8 @@ function vim.empty_dict() end --- This function also works in a fast callback |lua-loop-callbacks|. --- @param channel integer --- @param method string ---- @param args? any[] --- @param ...? any -function vim.rpcnotify(channel, method, args, ...) end +function vim.rpcnotify(channel, method, ...) end --- Sends a request to {channel} to invoke {method} via |RPC| and blocks until --- a response is received. @@ -102,9 +101,8 @@ function vim.rpcnotify(channel, method, args, ...) end --- special value --- @param channel integer --- @param method string ---- @param args? any[] --- @param ...? any -function vim.rpcrequest(channel, method, args, ...) end +function vim.rpcrequest(channel, method, ...) end --- Compares strings case-insensitively. --- @param a string diff --git a/runtime/lua/vim/_meta/options.lua b/runtime/lua/vim/_meta/options.lua index 5a9215fa9e..757720d8fb 100644 --- a/runtime/lua/vim/_meta/options.lua +++ b/runtime/lua/vim/_meta/options.lua @@ -5799,7 +5799,8 @@ vim.bo.sw = vim.bo.shiftwidth --- items, for instance "scanning tags" --- q do not show "recording @a" when recording a macro *shm-q* --- F don't give the file info when editing a file, like *shm-F* ---- `:silent` was used for the command +--- `:silent` was used for the command; note that this also +--- affects messages from 'autoread' reloading --- S do not show search count message when searching, e.g. *shm-S* --- "[1/5]" --- diff --git a/runtime/lua/vim/_meta/vimfn.lua b/runtime/lua/vim/_meta/vimfn.lua index 3c72d8be1d..ac25547212 100644 --- a/runtime/lua/vim/_meta/vimfn.lua +++ b/runtime/lua/vim/_meta/vimfn.lua @@ -3531,7 +3531,7 @@ function vim.fn.getreginfo(regname) end --- {pos1} and {pos2} must both be |List|s with four numbers. --- See |getpos()| for the format of the list. It's possible --- to specify positions from a different buffer, but please ---- note the limitations at |getregion-notes| +--- note the limitations at |getregion-notes|. --- --- The optional argument {opts} is a Dict and supports the --- following items: @@ -3565,9 +3565,9 @@ function vim.fn.getreginfo(regname) end --- - If {pos1} and {pos2} are not in the same buffer, an empty --- list is returned. --- - {pos1} and {pos2} must belong to a |bufloaded()| buffer. ---- - It is evaluated in current window context, this makes a ---- different if a buffer is displayed in a different window and ---- 'virtualedit' or 'list' is set +--- - It is evaluated in current window context, which makes a +--- difference if the buffer is displayed in a window with +--- different 'virtualedit' or 'list' values. --- --- Examples: > --- :xnoremap <CR> diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua index ef5d9d7cff..d5c376ba44 100644 --- a/runtime/lua/vim/lsp.lua +++ b/runtime/lua/vim/lsp.lua @@ -146,9 +146,10 @@ end local client_errors_base = table.maxn(lsp.rpc.client_errors) local client_errors_offset = 0 -local function new_error_index() +local function client_error(name) client_errors_offset = client_errors_offset + 1 - return client_errors_base + client_errors_offset + local index = client_errors_base + client_errors_offset + return { [name] = index, [index] = name } end --- Error codes to be used with `on_error` from |vim.lsp.start_client|. @@ -158,12 +159,10 @@ end lsp.client_errors = tbl_extend( 'error', lsp.rpc.client_errors, - vim.tbl_add_reverse_lookup({ - BEFORE_INIT_CALLBACK_ERROR = new_error_index(), - ON_INIT_CALLBACK_ERROR = new_error_index(), - ON_ATTACH_ERROR = new_error_index(), - ON_EXIT_CALLBACK_ERROR = new_error_index(), - }) + client_error('BEFORE_INIT_CALLBACK_ERROR'), + client_error('ON_INIT_CALLBACK_ERROR'), + client_error('ON_ATTACH_ERROR'), + client_error('ON_EXIT_CALLBACK_ERROR') ) ---@private diff --git a/runtime/lua/vim/lsp/log.lua b/runtime/lua/vim/lsp/log.lua index 018003bb81..9f2bd71158 100644 --- a/runtime/lua/vim/lsp/log.lua +++ b/runtime/lua/vim/lsp/log.lua @@ -2,16 +2,19 @@ local log = {} +local log_levels = vim.log.levels + --- Log level dictionary with reverse lookup as well. --- --- Can be used to lookup the number from the name or the name from the number. --- Levels by name: "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "OFF" --- Level numbers begin with "TRACE" at 0 +--- @type table<string|integer, string|integer> --- @nodoc -log.levels = vim.deepcopy(vim.log.levels) +log.levels = vim.deepcopy(log_levels) -- Default log level is warn. -local current_log_level = log.levels.WARN +local current_log_level = log_levels.WARN local log_date_format = '%F %H:%M:%S' @@ -58,7 +61,7 @@ local function open_logfile() logfile, openerr = io.open(logfilename, 'a+') if not logfile then local err_msg = string.format('Failed to open LSP client log file: %s', openerr) - notify(err_msg, vim.log.levels.ERROR) + notify(err_msg, log_levels.ERROR) return false end @@ -77,12 +80,13 @@ local function open_logfile() return true end -for level, levelnr in pairs(log.levels) do +for level, levelnr in pairs(log_levels) do -- Also export the log level on the root object. log[level] = levelnr -end -vim.tbl_add_reverse_lookup(log.levels) + -- Add a reverse lookup. + log.levels[levelnr] = level +end --- @param level string --- @param levelnr integer @@ -123,19 +127,19 @@ end -- log at that level (if applicable, it is checked either way). --- @nodoc -log.debug = create_logger('DEBUG', vim.log.levels.DEBUG) +log.debug = create_logger('DEBUG', log_levels.DEBUG) --- @nodoc -log.error = create_logger('ERROR', vim.log.levels.ERROR) +log.error = create_logger('ERROR', log_levels.ERROR) --- @nodoc -log.info = create_logger('INFO', vim.log.levels.INFO) +log.info = create_logger('INFO', log_levels.INFO) --- @nodoc -log.trace = create_logger('TRACE', vim.log.levels.TRACE) +log.trace = create_logger('TRACE', log_levels.TRACE) --- @nodoc -log.warn = create_logger('WARN', vim.log.levels.WARN) +log.warn = create_logger('WARN', log_levels.WARN) --- Sets the current log level. ---@param level (string|integer) One of `vim.lsp.log.levels` diff --git a/runtime/lua/vim/lsp/protocol.lua b/runtime/lua/vim/lsp/protocol.lua index 7016209372..599f02425e 100644 --- a/runtime/lua/vim/lsp/protocol.lua +++ b/runtime/lua/vim/lsp/protocol.lua @@ -1,22 +1,19 @@ --- @diagnostic disable: duplicate-doc-alias --- TODO(clason) can be simplified after reverse lookup is removed ----@param t table<any, any> ----@return number[] -local function get_value_set(t) - local result = {} - for _, v in pairs(t) do - if type(v) == 'number' then - table.insert(result, v) - end +---@param tbl table<string, string|number> +local function get_value_set(tbl) + local value_set = {} + for _, v in pairs(tbl) do + table.insert(value_set, v) end - table.sort(result) - return result + table.sort(value_set) + return value_set end -- Protocol for the Microsoft Language Server Protocol (mslsp) +local protocol = {} -local protocol = { +local constants = { --- @enum lsp.DiagnosticSeverity DiagnosticSeverity = { -- Reports an error. @@ -309,11 +306,13 @@ local protocol = { }, } --- TODO(mariasolos): Remove this reverse lookup. -for k, v in pairs(protocol) do - local tbl = vim.deepcopy(v, true) - vim.tbl_add_reverse_lookup(tbl) - protocol[k] = tbl +for k1, v1 in pairs(constants) do + local tbl = vim.deepcopy(v1, true) + for _, k2 in ipairs(vim.tbl_keys(tbl)) do + local v2 = tbl[k2] + tbl[v2] = k2 + end + protocol[k1] = tbl end --[=[ @@ -719,14 +718,7 @@ function protocol.make_client_capabilities() codeActionLiteralSupport = { codeActionKind = { - valueSet = (function() - local res = vim.iter.filter(function(value) - -- Filter out the keys that were added by the reverse lookup. - return value:match('^%l') - end, vim.tbl_values(protocol.CodeActionKind)) - table.sort(res) - return res - end)(), + valueSet = get_value_set(constants.CodeActionKind), }, }, isPreferredSupport = true, @@ -751,10 +743,10 @@ function protocol.make_client_capabilities() commitCharactersSupport = false, preselectSupport = false, deprecatedSupport = false, - documentationFormat = { protocol.MarkupKind.Markdown, protocol.MarkupKind.PlainText }, + documentationFormat = { constants.MarkupKind.Markdown, constants.MarkupKind.PlainText }, }, completionItemKind = { - valueSet = get_value_set(protocol.CompletionItemKind), + valueSet = get_value_set(constants.CompletionItemKind), }, completionList = { itemDefaults = { @@ -783,13 +775,13 @@ function protocol.make_client_capabilities() }, hover = { dynamicRegistration = true, - contentFormat = { protocol.MarkupKind.Markdown, protocol.MarkupKind.PlainText }, + contentFormat = { constants.MarkupKind.Markdown, constants.MarkupKind.PlainText }, }, signatureHelp = { dynamicRegistration = false, signatureInformation = { activeParameterSupport = true, - documentationFormat = { protocol.MarkupKind.Markdown, protocol.MarkupKind.PlainText }, + documentationFormat = { constants.MarkupKind.Markdown, constants.MarkupKind.PlainText }, parameterInformation = { labelOffsetSupport = true, }, @@ -804,7 +796,7 @@ function protocol.make_client_capabilities() documentSymbol = { dynamicRegistration = false, symbolKind = { - valueSet = get_value_set(protocol.SymbolKind), + valueSet = get_value_set(constants.SymbolKind), }, hierarchicalDocumentSymbolSupport = true, }, @@ -815,7 +807,7 @@ function protocol.make_client_capabilities() publishDiagnostics = { relatedInformation = true, tagSupport = { - valueSet = get_value_set(protocol.DiagnosticTag), + valueSet = get_value_set(constants.DiagnosticTag), }, dataSupport = true, }, @@ -827,7 +819,7 @@ function protocol.make_client_capabilities() symbol = { dynamicRegistration = false, symbolKind = { - valueSet = get_value_set(protocol.SymbolKind), + valueSet = get_value_set(constants.SymbolKind), }, }, configuration = true, @@ -867,9 +859,9 @@ end --- Creates a normalized object describing LSP server capabilities. ---@param server_capabilities table Table of capabilities supported by the server ----@return lsp.ServerCapabilities|nil Normalized table of capabilities +---@return lsp.ServerCapabilities|nil : Normalized table of capabilities function protocol.resolve_capabilities(server_capabilities) - local TextDocumentSyncKind = protocol.TextDocumentSyncKind + local TextDocumentSyncKind = protocol.TextDocumentSyncKind ---@type table<string|number, string|number> local textDocumentSync = server_capabilities.textDocumentSync if textDocumentSync == nil then -- Defaults if omitted. diff --git a/runtime/lua/vim/lsp/rpc.lua b/runtime/lua/vim/lsp/rpc.lua index 8e014b1063..984e4f040a 100644 --- a/runtime/lua/vim/lsp/rpc.lua +++ b/runtime/lua/vim/lsp/rpc.lua @@ -130,7 +130,7 @@ local M = {} --- Mapping of error codes used by the client --- @nodoc -M.client_errors = { +local client_errors = { INVALID_SERVER_MESSAGE = 1, INVALID_SERVER_JSON = 2, NO_RESULT_CALLBACK_FOUND = 3, @@ -140,7 +140,12 @@ M.client_errors = { SERVER_RESULT_CALLBACK_ERROR = 7, } -M.client_errors = vim.tbl_add_reverse_lookup(M.client_errors) +--- @type table<string|integer, string|integer> +--- @nodoc +M.client_errors = vim.deepcopy(client_errors) +for k, v in pairs(client_errors) do + M.client_errors[v] = k +end --- Constructs an error message from an LSP error object. --- diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua index 561d9e3f1b..bd553598c7 100644 --- a/runtime/lua/vim/shared.lua +++ b/runtime/lua/vim/shared.lua @@ -465,9 +465,12 @@ end --- `tbl_add_reverse_lookup { A = 1 } == { [1] = 'A', A = 1 }` --- --- Note that this *modifies* the input. +---@deprecated ---@param o table Table to add the reverse to ---@return table o function vim.tbl_add_reverse_lookup(o) + vim.deprecate('vim.tbl_add_reverse_lookup', nil, '0.12') + --- @cast o table<any,any> --- @type any[] local keys = vim.tbl_keys(o) diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 94c9af50d4..b7120d5dd5 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -4365,7 +4365,7 @@ M.funcs = { {pos1} and {pos2} must both be |List|s with four numbers. See |getpos()| for the format of the list. It's possible to specify positions from a different buffer, but please - note the limitations at |getregion-notes| + note the limitations at |getregion-notes|. The optional argument {opts} is a Dict and supports the following items: @@ -4399,9 +4399,9 @@ M.funcs = { - If {pos1} and {pos2} are not in the same buffer, an empty list is returned. - {pos1} and {pos2} must belong to a |bufloaded()| buffer. - - It is evaluated in current window context, this makes a - different if a buffer is displayed in a different window and - 'virtualedit' or 'list' is set + - It is evaluated in current window context, which makes a + difference if the buffer is displayed in a window with + different 'virtualedit' or 'list' values. Examples: > :xnoremap <CR> diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 67443b66bc..2f9472f158 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -2862,7 +2862,7 @@ static void f_getregion(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) return; } - buf_T *save_curbuf = curbuf; + buf_T *const save_curbuf = curbuf; if (fnum1 != 0) { buf_T *findbuf = buflist_findnr(fnum1); @@ -2870,7 +2870,6 @@ static void f_getregion(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) if (findbuf == NULL || findbuf->b_ml.ml_mfp == NULL) { return; } - save_curbuf = curbuf; curbuf = findbuf; } diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 2c96e4bd87..695631a6f7 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -3153,7 +3153,7 @@ void buf_reload(buf_T *buf, int orig_mode, bool reload_options) curbuf->b_flags |= BF_CHECK_RO; // check for RO again keep_filetype = true; // don't detect 'filetype' if (readfile(buf->b_ffname, buf->b_fname, 0, 0, - (linenr_T)MAXLNUM, &ea, flags, false) != OK) { + (linenr_T)MAXLNUM, &ea, flags, shortmess(SHM_FILEINFO)) != OK) { if (!aborting()) { semsg(_("E321: Could not reload \"%s\""), buf->b_fname); } diff --git a/src/nvim/options.lua b/src/nvim/options.lua index 4452df413a..72f9ff849d 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -7331,7 +7331,8 @@ return { items, for instance "scanning tags" q do not show "recording @a" when recording a macro *shm-q* F don't give the file info when editing a file, like *shm-F* - `:silent` was used for the command + `:silent` was used for the command; note that this also + affects messages from 'autoread' reloading S do not show search count message when searching, e.g. *shm-S* "[1/5]" diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index 0d4452662d..5b1cb01976 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -586,6 +586,9 @@ void expand_env_esc(char *restrict srcp, char *restrict dst, int dstlen, bool es bool copy_char; bool mustfree; // var was allocated, need to free it later bool at_start = true; // at start of a name +#if defined(BACKSLASH_IN_FILENAME) + char *const save_dst = dst; +#endif int prefix_len = (prefix == NULL) ? 0 : (int)strlen(prefix); @@ -726,7 +729,7 @@ void expand_env_esc(char *restrict srcp, char *restrict dst, int dstlen, bool es // with it, skip a character if (after_pathsep(dst, dst + c) #if defined(BACKSLASH_IN_FILENAME) - && dst[-1] != ':' + && (dst == save_dst || dst[-1] != ':') #endif && vim_ispathsep(*tail)) { tail++; diff --git a/src/nvim/os/pty_process_win.c b/src/nvim/os/pty_process_win.c index fdc06f9804..12831ff05f 100644 --- a/src/nvim/os/pty_process_win.c +++ b/src/nvim/os/pty_process_win.c @@ -32,11 +32,10 @@ static void start_wait_eof_timer(void **argv) FUNC_ATTR_NONNULL_ALL { PtyProcess *ptyproc = (PtyProcess *)argv[0]; - Process *proc = (Process *)ptyproc; - uv_timer_init(&proc->loop->uv, &ptyproc->wait_eof_timer); - ptyproc->wait_eof_timer.data = (void *)ptyproc; - uv_timer_start(&ptyproc->wait_eof_timer, wait_eof_timer_cb, 200, 200); + if (ptyproc->finish_wait != NULL) { + uv_timer_start(&ptyproc->wait_eof_timer, wait_eof_timer_cb, 200, 200); + } } /// @returns zero on success, or negative error code. @@ -117,6 +116,8 @@ int pty_process_spawn(PtyProcess *ptyproc) } proc->pid = (int)GetProcessId(process_handle); + uv_timer_init(&proc->loop->uv, &ptyproc->wait_eof_timer); + ptyproc->wait_eof_timer.data = (void *)ptyproc; if (!RegisterWaitForSingleObject(&ptyproc->finish_wait, process_handle, pty_process_finish1, @@ -176,6 +177,16 @@ void pty_process_close(PtyProcess *ptyproc) pty_process_close_master(ptyproc); + if (ptyproc->finish_wait != NULL) { + UnregisterWaitEx(ptyproc->finish_wait, NULL); + ptyproc->finish_wait = NULL; + uv_close((uv_handle_t *)&ptyproc->wait_eof_timer, NULL); + } + if (ptyproc->process_handle != NULL) { + CloseHandle(ptyproc->process_handle); + ptyproc->process_handle = NULL; + } + if (proc->internal_close_cb) { proc->internal_close_cb(proc); } @@ -204,6 +215,7 @@ static void wait_eof_timer_cb(uv_timer_t *wait_eof_timer) PtyProcess *ptyproc = wait_eof_timer->data; Process *proc = (Process *)ptyproc; + assert(ptyproc->finish_wait != NULL); if (proc->out.closed || proc->out.did_eof || !uv_is_readable(proc->out.uvstream)) { uv_timer_stop(&ptyproc->wait_eof_timer); pty_process_finish2(ptyproc); @@ -215,16 +227,10 @@ static void pty_process_finish2(PtyProcess *ptyproc) { Process *proc = (Process *)ptyproc; - UnregisterWaitEx(ptyproc->finish_wait, NULL); - uv_close((uv_handle_t *)&ptyproc->wait_eof_timer, NULL); - DWORD exit_code = 0; GetExitCodeProcess(ptyproc->process_handle, &exit_code); proc->status = proc->exit_signal ? 128 + proc->exit_signal : (int)exit_code; - CloseHandle(ptyproc->process_handle); - ptyproc->process_handle = NULL; - proc->internal_exit_cb(proc); } diff --git a/test/functional/autocmd/focus_spec.lua b/test/functional/autocmd/focus_spec.lua index b9bab206fc..4f4a036ba8 100644 --- a/test/functional/autocmd/focus_spec.lua +++ b/test/functional/autocmd/focus_spec.lua @@ -86,7 +86,7 @@ describe('autoread TUI FocusGained/FocusLost', function() line 3 | line 4 | {5:xtest-foo }| - "xtest-foo" 4L, 28B | + :edit xtest-foo | {3:-- TERMINAL --} | ]], } diff --git a/test/functional/plugin/tohtml_spec.lua b/test/functional/plugin/tohtml_spec.lua index 0d0f10671f..2ac0fe1fa3 100644 --- a/test/functional/plugin/tohtml_spec.lua +++ b/test/functional/plugin/tohtml_spec.lua @@ -115,18 +115,20 @@ end ---@param func function? local function run_tohtml_and_assert(screen, func) exec('norm! ggO-;') - exec('norm! gg0f;:\r') - screen:sleep(10) - local snapshot = { grid = screen:get_snapshot().grid, attr_ids = screen:get_snapshot().attr_ids } + screen:expect({ any = vim.pesc('-^;') }) + exec('norm! :\rh') + screen:expect({ any = vim.pesc('^-;') }) + local expected = screen:get_snapshot() do (func or exec)('TOhtml') end exec('only') html_syntax_match() html_to_extmarks() - exec('norm! gg0f;:\r') - screen:sleep(10) - eq(snapshot, { grid = screen:get_snapshot().grid, attr_ids = screen:get_snapshot().attr_ids }) + exec('norm! gg0f;') + screen:expect({ any = vim.pesc('-^;') }) + exec('norm! :\rh') + screen:expect({ grid = expected.grid, attr_ids = expected.attr_ids }) end describe(':TOhtml', function() @@ -288,7 +290,7 @@ describe(':TOhtml', function() --api.nvim_buf_set_extmark(0,ns,3,0,{virt_text={{'foo'}},virt_text_pos='right_align'}) run_tohtml_and_assert(screen) end) - it('highlgith', function() + it('highlight', function() insert [[ line1 ]] diff --git a/test/old/testdir/runnvim.vim b/test/old/testdir/runnvim.vim index 3ccb9988cf..578614c8a1 100644 --- a/test/old/testdir/runnvim.vim +++ b/test/old/testdir/runnvim.vim @@ -25,8 +25,7 @@ function Main() set lines=25 set columns=80 enew - " FIXME: using termopen() hangs on Windows CI - let job = has('win32') ? jobstart(args, s:logger) : termopen(args, s:logger) + let job = termopen(args, s:logger) let results = jobwait([job], 5 * 60 * 1000) " TODO(ZyX-I): Get colors let screen = getline(1, '$') diff --git a/test/old/testdir/test_options.vim b/test/old/testdir/test_options.vim index e772a7bb55..7786f82af2 100644 --- a/test/old/testdir/test_options.vim +++ b/test/old/testdir/test_options.vim @@ -1283,6 +1283,44 @@ func Test_shortmess_F2() " call assert_fails('call test_getvalue("abc")', 'E475:') endfunc +func Test_shortmess_F3() + call writefile(['foo'], 'X_dummy', 'D') + + set hidden + set autoread + e X_dummy + e Xotherfile + call assert_equal(['foo'], getbufline('X_dummy', 1, '$')) + set shortmess+=F + echo '' + + if has('nanotime') + sleep 10m + else + sleep 2 + endif + call writefile(['bar'], 'X_dummy') + bprev + call assert_equal('', Screenline(&lines)) + call assert_equal(['bar'], getbufline('X_dummy', 1, '$')) + + if has('nanotime') + sleep 10m + else + sleep 2 + endif + call writefile(['baz'], 'X_dummy') + checktime + call assert_equal('', Screenline(&lines)) + call assert_equal(['baz'], getbufline('X_dummy', 1, '$')) + + set shortmess& + set autoread& + set hidden& + bwipe X_dummy + bwipe Xotherfile +endfunc + func Test_local_scrolloff() set so=5 set siso=7 diff --git a/test/old/testdir/test_undo.vim b/test/old/testdir/test_undo.vim index a06731cc96..a207f4f4e0 100644 --- a/test/old/testdir/test_undo.vim +++ b/test/old/testdir/test_undo.vim @@ -588,7 +588,7 @@ funct Test_undofile() endif call assert_equal('', undofile('')) - " Test undofile() with 'undodir' set to to an existing directory. + " Test undofile() with 'undodir' set to an existing directory. call mkdir('Xundodir') set undodir=Xundodir let cwd = getcwd() |