diff options
100 files changed, 2753 insertions, 927 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e89873b39f..97e1ed8742 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,6 +55,7 @@ jobs: - name: Install brew packages if: matrix.os == 'osx' run: | + rm -f /usr/local/bin/2to3 brew update >/dev/null brew install automake ccache cpanminus ninja brew upgrade diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d7f9556028..6905f8dd35 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -75,6 +75,7 @@ jobs: fetch-depth: 0 - name: Install brew packages run: | + rm -f /usr/local/bin/2to3 brew update >/dev/null brew install automake ninja - name: Build release diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index 755e7becb3..c4b4594290 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -376,7 +376,7 @@ on writing and loading a buffer to file, nor in undo/redo cycles. Highlights are registered using the |nvim_buf_add_highlight()| function. If an external highlighter plugin wants to add many highlights in a batch, performance can be improved by calling |nvim_buf_add_highlight()| as an -asynchronous notification, after first (synchronously) reqesting a source id. +asynchronous notification, after first (synchronously) requesting a source id. Example using the Python API client (|pynvim|): > @@ -646,6 +646,9 @@ nvim_create_namespace({name}) *nvim_create_namespace()* nvim_del_current_line() *nvim_del_current_line()* Deletes the current line. + Attributes: ~ + not allowed when |textlock| is active + nvim_del_keymap({mode}, {lhs}) *nvim_del_keymap()* Unmaps a global |mapping| for the given mode. @@ -755,6 +758,15 @@ nvim_feedkeys({keys}, {mode}, {escape_csi}) *nvim_feedkeys()* feedkeys() vim_strsave_escape_csi +nvim_get_all_options_info() *nvim_get_all_options_info()* + Gets the option information for all options. + + The dictionary has the full option names as keys and option + metadata dictionaries as detailed at |nvim_get_option_info|. + + Return: ~ + dictionary of all options + nvim_get_api_info() *nvim_get_api_info()* Returns a 2-tuple (Array), where item 0 is the current channel id and item 1 is the |api-metadata| map (Dictionary). @@ -937,22 +949,18 @@ nvim_get_option_info({name}) *nvim_get_option_info()* Gets the option information for one option Resulting dictionary has keys: - • name (string): Name of the option - • shortname (shortname): Shortened name of the option - • type (string): Name of the type of option - • default (Any): The default value for the option - - Script-Related Keys: - • was_set (bool): Whether the option was set. - • last_set_sid (int): Last set script id - • last_set_linenr (int): Last set script id, -1 if invalid. - • last_set_lchan (int): Last set script id, -1 if invalid. - - Flag-Related Keys: - • win (bool): Window-local option - • buf (bool): Buffer-local option - • global_local (bool): Global or Buffer local option - • flaglist (bool): List of single char flags + • name: Name of the option (like 'filetype') + • shortname: Shortened name of the option (like 'ft') + • type: type of option ("string", "integer" or "boolean") + • default: The default value for the option + • was_set: Whether the option was set. + • last_set_sid: Last set script id (if any) + • last_set_linenr: line number where option was set + • last_set_chan: Channel where option was set (0 for local) + • scope: one of "global", "win", or "buf" + • global_local: whether win or buf option has a global value + • commalist: List of comma separated values + • flaglist: List of single char flags Parameters: ~ {name} Option name @@ -960,12 +968,6 @@ nvim_get_option_info({name}) *nvim_get_option_info()* Return: ~ Option Information -nvim_get_options_info() *nvim_get_options_info()* - Gets the option information for all options. - - Return: ~ - Map<option_name, option_info> - nvim_get_proc({pid}) *nvim_get_proc()* Gets info describing process `pid` . @@ -1174,6 +1176,9 @@ nvim_open_win({buffer}, {enter}, {config}) *nvim_open_win()* {relative='win', width=12, height=3, bufpos={100,10}}) < + Attributes: ~ + not allowed when |textlock| is active + Parameters: ~ {buffer} Buffer to display, or 0 for current buffer {enter} Enter the window (make it the current window) @@ -1352,6 +1357,9 @@ nvim_paste({data}, {crlf}, {phase}) *nvim_paste()* calls are ignored ("drained") until the next paste is initiated (phase 1 or -1). + Attributes: ~ + not allowed when |textlock| is active + Parameters: ~ {data} Multiline input. May be binary (containing NUL bytes). @@ -1372,6 +1380,9 @@ nvim_put({lines}, {type}, {after}, {follow}) *nvim_put()* Compare |:put| and |p| which are always linewise. + Attributes: ~ + not allowed when |textlock| is active + Parameters: ~ {lines} |readfile()|-style list of lines. |channel-lines| @@ -1489,6 +1500,9 @@ nvim_set_client_info({name}, {version}, {type}, {methods}, {attributes}) nvim_set_current_buf({buffer}) *nvim_set_current_buf()* Sets the current buffer. + Attributes: ~ + not allowed when |textlock| is active + Parameters: ~ {buffer} Buffer handle @@ -1501,18 +1515,27 @@ nvim_set_current_dir({dir}) *nvim_set_current_dir()* nvim_set_current_line({line}) *nvim_set_current_line()* Sets the current line. + Attributes: ~ + not allowed when |textlock| is active + Parameters: ~ {line} Line contents nvim_set_current_tabpage({tabpage}) *nvim_set_current_tabpage()* Sets the current tabpage. + Attributes: ~ + not allowed when |textlock| is active + Parameters: ~ {tabpage} Tabpage handle nvim_set_current_win({window}) *nvim_set_current_win()* Sets the current window. + Attributes: ~ + not allowed when |textlock| is active + Parameters: ~ {window} Window handle @@ -1859,6 +1882,9 @@ nvim_buf_del_var({buffer}, {name}) *nvim_buf_del_var()* nvim_buf_delete({buffer}, {opts}) *nvim_buf_delete()* Deletes the buffer. See |:bwipeout| + Attributes: ~ + not allowed when |textlock| is active + Parameters: ~ {buffer} Buffer handle, or 0 for current buffer {opts} Optional parameters. Keys: @@ -2155,6 +2181,9 @@ nvim_buf_set_lines({buffer}, {start}, {end}, {strict_indexing}, {replacement}) Out-of-bounds indices are clamped to the nearest valid value, unless `strict_indexing` is set. + Attributes: ~ + not allowed when |textlock| is active + Parameters: ~ {buffer} Buffer handle, or 0 for current buffer {start} First line index @@ -2232,6 +2261,9 @@ Window Functions *api-window* nvim_win_close({window}, {force}) *nvim_win_close()* Closes the window (like |:close| with a |window-ID|). + Attributes: ~ + not allowed when |textlock| is active + Parameters: ~ {window} Window handle, or 0 for current window {force} Behave like `:close!` The last window of a @@ -2357,6 +2389,9 @@ nvim_win_is_valid({window}) *nvim_win_is_valid()* nvim_win_set_buf({window}, {buffer}) *nvim_win_set_buf()* Sets the current buffer in a window, without side-effects + Attributes: ~ + not allowed when |textlock| is active + Parameters: ~ {window} Window handle, or 0 for current window {buffer} Buffer handle diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt index 5c67359002..f3ed086933 100644 --- a/runtime/doc/change.txt +++ b/runtime/doc/change.txt @@ -954,9 +954,13 @@ inside of strings can change! Also see 'softtabstop' option. > delete and yank) ({.%#:} only work with put). *:reg* *:registers* -:reg[isters] Display the contents of all numbered and named - registers. If a register is written to for |:redir| - it will not be listed. +:reg[isters] Display the type and contents of all numbered and + named registers. If a register is written to for + |:redir| it will not be listed. + Type can be one of: + "c" for |characterwise| text + "l" for |linewise| text + "b" for |blockwise-visual| text :reg[isters] {arg} Display the contents of the numbered and named diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt index ea9072841c..67e2815715 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -1120,7 +1120,7 @@ get_line_diagnostics({bufnr}, {line_nr}, {opts}, {client_id}) diagnostics. get_next({opts}) *vim.lsp.diagnostic.get_next()* - Get the previous diagnostic closest to the cursor_position + Get the next diagnostic closest to the cursor_position Parameters: ~ {opts} table See |vim.lsp.diagnostic.goto_next()| diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 6c42dd6739..e740a45bec 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -2438,7 +2438,7 @@ A jump table for the options with a short description can be found at |Q_op|. 'foldcolumn' 'fdc' string (default "0") local to window When and how to draw the foldcolumn. Valid values are: - "auto": resize to the maximum amount of folds to display. + "auto": resize to the minimum amount of folds to display. "auto:[1-9]": resize to accommodate multiple folds up to the selected level 0: to disable foldcolumn diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt index cd6186834d..911e7b8b47 100644 --- a/runtime/doc/treesitter.txt +++ b/runtime/doc/treesitter.txt @@ -197,11 +197,11 @@ query:iter_captures({node}, {bufnr}, {start_row}, {end_row}) as the node, i e to get syntax highlight matches in the current viewport) - The iterator returns two values, a numeric id identifying the capture - and the captured node. The following example shows how to get captures - by name: + The iterator returns three values, a numeric id identifying the capture, + the captured node, and metadata from any directives processing the match. + The following example shows how to get captures by name: > - for id, node in query:iter_captures(tree:root(), bufnr, first, last) do + for id, node, metadata in query:iter_captures(tree:root(), bufnr, first, last) do local name = query.captures[id] -- name of the capture in the query -- typically useful info about the node: local type = node:type() -- type of the captured node @@ -213,16 +213,19 @@ query:iter_matches({node}, {bufnr}, {start_row}, {end_row}) *query:iter_matches()* Iterate over all matches within a node. The arguments are the same as for |query:iter_captures()| but the iterated values are different: - an (1-based) index of the pattern in the query, and a table mapping - capture indices to nodes. If the query has more than one pattern - the capture table might be sparse, and e.g. `pairs` should be used and not - `ipairs`. Here an example iterating over all captures in - every match: + an (1-based) index of the pattern in the query, a table mapping + capture indices to nodes, and metadata from any directives processing the match. + If the query has more than one pattern the capture table might be sparse, + and e.g. `pairs()` method should be used over `ipairs`. + Here an example iterating over all captures in every match: > - for pattern, match in cquery:iter_matches(tree:root(), bufnr, first, last) do - for id,node in pairs(match) do + for pattern, match, metadata in cquery:iter_matches(tree:root(), bufnr, first, last) do + for id, node in pairs(match) do local name = query.captures[id] -- `node` was captured by the `name` capture in the match + + local node_data = metadata[id] -- Node level metadata + ... use the info here ... end end @@ -265,6 +268,29 @@ Here is a list of built-in predicates : Each predicate has a `not-` prefixed predicate that is just the negation of the predicate. +Treesitter Query Directive *lua-treesitter-directives* + +Treesitter queries can also contain `directives`. Directives store metadata for a node +or match and perform side effects. for example, the |set!| predicate sets metadata on +the match or node : > + ((identifier) @foo (#set! "type" "parameter")) + +Here is a list of built-in directives: + + `set!` *ts-directive-set!* + Sets key/value metadata for a specific node or match : > + ((identifier) @foo (#set! @foo "kind" "parameter")) + ((node1) @left (node2) @right (#set! "type" "pair")) +< + `offset!` *ts-predicate-offset!* + Takes the range of the captured node and applies the offsets + to it's range : > + ((idenfitier) @constant (#offset! @constant 0 1 0 -1)) +< This will generate a range object for the captured node with the + offsets applied. The arguments are + `({capture_id}, {start_row}, {start_col}, {end_row}, {end_col}, {key?})` + The default key is "offset". + *vim.treesitter.query.add_predicate()* vim.treesitter.query.add_predicate({name}, {handler}) @@ -277,6 +303,16 @@ vim.treesitter.query.list_predicates() This lists the currently available predicates to use in queries. + *vim.treesitter.query.add_directive()* +vim.treesitter.query.add_directive({name}, {handler}) + +This adds a directive with the name {name} to be used in queries. +{handler} should be a function whose signature will be : > + handler(match, pattern, bufnr, predicate, metadata) +Handlers can set match level data by setting directly on the metadata object `metadata.key = value` +Handlers can set node level data by using the capture id on the metadata table +`metadata[capture_id].key = value` + Treesitter syntax highlighting (WIP) *lua-treesitter-highlight* NOTE: This is a partially implemented feature, and not usable as a default diff --git a/runtime/filetype.vim b/runtime/filetype.vim index ed3204c537..d2083b23d3 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -623,6 +623,9 @@ au BufNewFile,BufRead *.mo,*.gdmo setf gdmo " Gedcom au BufNewFile,BufRead *.ged,lltxxxxx.txt setf gedcom +" Gift (Moodle) +autocmd BufRead,BufNewFile *.gift setf gift + " Git au BufNewFile,BufRead COMMIT_EDITMSG,MERGE_MSG,TAG_EDITMSG setf gitcommit au BufNewFile,BufRead *.git/config,.gitconfig,/etc/gitconfig setf gitconfig diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua index ed31572abb..0326550245 100644 --- a/runtime/lua/vim/lsp.lua +++ b/runtime/lua/vim/lsp.lua @@ -569,6 +569,8 @@ function lsp.start_client(config) -- TODO(remove-callbacks) callbacks = handlers; handlers = handlers; + -- for $/progress report + messages = { name = name, messages = {}, progress = {}, status = {} } } -- Store the uninitialized_clients for cleanup in case we exit before initialize finishes. @@ -881,8 +883,8 @@ function lsp._text_document_did_save_handler(bufnr) client.notify('textDocument/didSave', { textDocument = { uri = uri; - text = included_text; - } + }; + text = included_text; }) end end) diff --git a/runtime/lua/vim/lsp/diagnostic.lua b/runtime/lua/vim/lsp/diagnostic.lua index efca5b53af..072349b226 100644 --- a/runtime/lua/vim/lsp/diagnostic.lua +++ b/runtime/lua/vim/lsp/diagnostic.lua @@ -1044,6 +1044,8 @@ function M.display(diagnostics, bufnr, client_id, config) diagnostics = diagnostics or M.get(bufnr, client_id) + vim.api.nvim_command("doautocmd <nomodeline> User LspDiagnosticsChanged") + if not diagnostics or vim.tbl_isempty(diagnostics) then return end @@ -1062,8 +1064,6 @@ function M.display(diagnostics, bufnr, client_id, config) if signs_opts then M.set_signs(diagnostics, bufnr, client_id, nil, signs_opts) end - - vim.api.nvim_command("doautocmd User LspDiagnosticsChanged") end -- }}} -- Diagnostic User Functions {{{ diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua index e034923afb..359573beb1 100644 --- a/runtime/lua/vim/lsp/handlers.lua +++ b/runtime/lua/vim/lsp/handlers.lua @@ -24,6 +24,47 @@ M['workspace/executeCommand'] = function(err, _) end end +-- @msg of type ProgressParams +-- Basically a token of type number/string +local function progress_callback(_, _, params, client_id) + local client = vim.lsp.get_client_by_id(client_id) + if not client then + err_message("LSP[", client_id, "] client has shut down after sending the message") + end + local val = params.value -- unspecified yet + local token = params.token -- string or number + + + if val.kind then + if val.kind == 'begin' then + client.messages.progress[token] = { + title = val.title, + message = val.message, + percentage = val.percentage, + } + elseif val.kind == 'report' then + client.messages.progress[token] = { + message = val.message, + percentage = val.percentage, + } + elseif val.kind == 'end' then + if client.messages.progress[token] == nil then + err_message( + 'echom "[lsp-status] Received `end` message with no corresponding `begin` from "') + else + client.messages.progress[token].message = val.message + client.messages.progress[token].done = true + end + end + else + table.insert(client.messages, {content = val, show_once = true, shown = 0}) + end + + vim.api.nvim_command("doautocmd <nomodeline> User LspProgressUpdate") +end + +M['$/progress'] = progress_callback + --@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_codeAction M['textDocument/codeAction'] = function(_, _, actions) if actions == nil or vim.tbl_isempty(actions) then @@ -212,9 +253,8 @@ M['textDocument/signatureHelp'] = function(_, method, result) end --@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_documentHighlight -M['textDocument/documentHighlight'] = function(_, _, result, _) +M['textDocument/documentHighlight'] = function(_, _, result, _, bufnr, _) if not result then return end - local bufnr = api.nvim_get_current_buf() util.buf_highlight_references(bufnr, result) end diff --git a/runtime/lua/vim/lsp/protocol.lua b/runtime/lua/vim/lsp/protocol.lua index fd86d8bb97..b785d2f586 100644 --- a/runtime/lua/vim/lsp/protocol.lua +++ b/runtime/lua/vim/lsp/protocol.lua @@ -728,6 +728,9 @@ function protocol.make_client_capabilities() dynamicRegistration = false; }; experimental = nil; + window = { + workDoneProgress = true; + } } end diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index 3da4dd6219..0972ea83c4 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -120,6 +120,63 @@ local function get_line_byte_from_position(bufnr, position) return col end +--- Process and return progress reports from lsp server +function M.get_progress_messages() + + local new_messages = {} + local msg_remove = {} + local progress_remove = {} + + for _, client in ipairs(vim.lsp.get_active_clients()) do + local messages = client.messages + local data = messages + for token, ctx in pairs(data.progress) do + + local new_report = { + name = data.name, + title = ctx.title or "empty title", + message = ctx.message, + percentage = ctx.percentage, + progress = true, + } + table.insert(new_messages, new_report) + + if ctx.done then + table.insert(progress_remove, {client = client, token = token}) + end + end + + for i, msg in ipairs(data.messages) do + if msg.show_once then + msg.shown = msg.shown + 1 + if msg.shown > 1 then + table.insert(msg_remove, {client = client, idx = i}) + end + end + + table.insert(new_messages, {name = data.name, content = msg.content}) + end + + if next(data.status) ~= nil then + table.insert(new_messages, { + name = data.name, + content = data.status.content, + uri = data.status.uri, + status = true + }) + end + for _, item in ipairs(msg_remove) do + table.remove(client.messages, item.idx) + end + + for _, item in ipairs(progress_remove) do + client.messages.progress[item.token] = nil + end + end + + return new_messages +end + --- Applies a list of text edits to a buffer. --@param text_edits (table) list of `TextEdit` objects --@param buf_nr (number) Buffer id diff --git a/runtime/lua/vim/treesitter.lua b/runtime/lua/vim/treesitter.lua index 6886f0c178..79dcf77f9e 100644 --- a/runtime/lua/vim/treesitter.lua +++ b/runtime/lua/vim/treesitter.lua @@ -50,7 +50,7 @@ function M._create_parser(bufnr, lang, opts) end end - a.nvim_buf_attach(self.bufnr, false, {on_bytes=bytes_cb, on_detach=detach_cb}) + a.nvim_buf_attach(self.bufnr, false, {on_bytes=bytes_cb, on_detach=detach_cb, preview=true}) self:parse() diff --git a/runtime/lua/vim/treesitter/languagetree.lua b/runtime/lua/vim/treesitter/languagetree.lua index 04b5fee256..9c620c422c 100644 --- a/runtime/lua/vim/treesitter/languagetree.lua +++ b/runtime/lua/vim/treesitter/languagetree.lua @@ -289,7 +289,7 @@ function LanguageTree:_get_injections() local root_node = tree:root() local start_line, _, end_line, _ = root_node:range() - for pattern, match in self._injection_query:iter_matches(root_node, self._source, start_line, end_line+1) do + for pattern, match, metadata in self._injection_query:iter_matches(root_node, self._source, start_line, end_line+1) do local lang = nil local injection_node = nil local combined = false @@ -298,9 +298,9 @@ function LanguageTree:_get_injections() -- using a tag with the language, for example -- @javascript for id, node in pairs(match) do + local data = metadata[id] local name = self._injection_query.captures[id] - -- TODO add a way to offset the content passed to the parser. - -- Needed to shave off leading quotes and things of that nature. + local offset_range = data and data.offset -- Lang should override any other language tag if name == "language" then @@ -308,7 +308,7 @@ function LanguageTree:_get_injections() elseif name == "combined" then combined = true elseif name == "content" then - injection_node = node + injection_node = offset_range or node -- Ignore any tags that start with "_" -- Allows for other tags to be used in matches elseif string.sub(name, 1, 1) ~= "_" then @@ -317,7 +317,7 @@ function LanguageTree:_get_injections() end if not injection_node then - injection_node = node + injection_node = offset_range or node end end end diff --git a/runtime/lua/vim/treesitter/query.lua b/runtime/lua/vim/treesitter/query.lua index 3537ba78f5..682f981fbc 100644 --- a/runtime/lua/vim/treesitter/query.lua +++ b/runtime/lua/vim/treesitter/query.lua @@ -92,6 +92,17 @@ local function read_query_files(filenames) return table.concat(contents, '\n') end +local match_metatable = { + __index = function(tbl, key) + rawset(tbl, key, {}) + return tbl[key] + end +} + +local function new_match_metadata() + return setmetatable({}, match_metatable) +end + --- Returns the runtime query {query_name} for {lang}. -- -- @param lang The language to use for the query @@ -222,6 +233,44 @@ local predicate_handlers = { -- As we provide lua-match? also expose vim-match? predicate_handlers["vim-match?"] = predicate_handlers["match?"] + +-- Directives store metadata or perform side effects against a match. +-- Directives should always end with a `!`. +-- Directive handler receive the following arguments +-- (match, pattern, bufnr, predicate) +local directive_handlers = { + ["set!"] = function(_, _, _, pred, metadata) + if #pred == 4 then + -- (set! @capture "key" "value") + metadata[pred[2]][pred[3]] = pred[4] + else + -- (set! "key" "value") + metadata[pred[2]] = pred[3] + end + end, + -- Shifts the range of a node. + -- Example: (#offset! @_node 0 1 0 -1) + ["offset!"] = function(match, _, _, pred, metadata) + local offset_node = match[pred[2]] + local range = {offset_node:range()} + local start_row_offset = pred[3] or 0 + local start_col_offset = pred[4] or 0 + local end_row_offset = pred[5] or 0 + local end_col_offset = pred[6] or 0 + local key = pred[7] or "offset" + + range[1] = range[1] + start_row_offset + range[2] = range[2] + start_col_offset + range[3] = range[3] + end_row_offset + range[4] = range[4] + end_col_offset + + -- If this produces an invalid range, we just skip it. + if range[1] < range[3] or (range[1] == range[3] and range[2] <= range[4]) then + metadata[pred[2]][key] = range + end + end +} + --- Adds a new predicates to be used in queries -- -- @param name the name of the predicate, without leading # @@ -229,12 +278,25 @@ predicate_handlers["vim-match?"] = predicate_handlers["match?"] -- signature will be (match, pattern, bufnr, predicate) function M.add_predicate(name, handler, force) if predicate_handlers[name] and not force then - a.nvim_err_writeln(string.format("Overriding %s", name)) + error(string.format("Overriding %s", name)) end predicate_handlers[name] = handler end +--- Adds a new directive to be used in queries +-- +-- @param name the name of the directive, without leading # +-- @param handler the handler function to be used +-- signature will be (match, pattern, bufnr, predicate) +function M.add_directive(name, handler, force) + if directive_handlers[name] and not force then + error(string.format("Overriding %s", name)) + end + + directive_handlers[name] = handler +end + --- Returns the list of currently supported predicates function M.list_predicates() return vim.tbl_keys(predicate_handlers) @@ -244,6 +306,10 @@ local function xor(x, y) return (x or y) and not (x and y) end +local function is_directive(name) + return string.sub(name, -1) == "!" +end + function Query:match_preds(match, pattern, source) local preds = self.info.patterns[pattern] @@ -254,30 +320,52 @@ function Query:match_preds(match, pattern, source) -- Also, tree-sitter strips the leading # from predicates for us. local pred_name local is_not - if string.sub(pred[1], 1, 4) == "not-" then - pred_name = string.sub(pred[1], 5) - is_not = true - else - pred_name = pred[1] - is_not = false - end - local handler = predicate_handlers[pred_name] + -- Skip over directives... they will get processed after all the predicates. + if not is_directive(pred[1]) then + if string.sub(pred[1], 1, 4) == "not-" then + pred_name = string.sub(pred[1], 5) + is_not = true + else + pred_name = pred[1] + is_not = false + end + + local handler = predicate_handlers[pred_name] - if not handler then - a.nvim_err_writeln(string.format("No handler for %s", pred[1])) - return false - end + if not handler then + error(string.format("No handler for %s", pred[1])) + return false + end - local pred_matches = handler(match, pattern, source, pred) + local pred_matches = handler(match, pattern, source, pred) - if not xor(is_not, pred_matches) then - return false + if not xor(is_not, pred_matches) then + return false + end end end return true end +--- Applies directives against a match and pattern. +function Query:apply_directives(match, pattern, source, metadata) + local preds = self.info.patterns[pattern] + + for _, pred in pairs(preds or {}) do + if is_directive(pred[1]) then + local handler = directive_handlers[pred[1]] + + if not handler then + error(string.format("No handler for %s", pred[1])) + return + end + + handler(match, pattern, source, pred, metadata) + end + end +end + --- Iterates of the captures of self on a given range. -- -- @param node The node under witch the search will occur @@ -294,14 +382,18 @@ function Query:iter_captures(node, source, start, stop) local raw_iter = node:_rawquery(self.query, true, start, stop) local function iter() local capture, captured_node, match = raw_iter() + local metadata = new_match_metadata() + if match ~= nil then local active = self:match_preds(match, match.pattern, source) match.active = active if not active then return iter() -- tail call: try next match end + + self:apply_directives(match, match.pattern, source, metadata) end - return capture, captured_node + return capture, captured_node, metadata end return iter end @@ -322,13 +414,17 @@ function Query:iter_matches(node, source, start, stop) local raw_iter = node:_rawquery(self.query, false, start, stop) local function iter() local pattern, match = raw_iter() + local metadata = new_match_metadata() + if match ~= nil then local active = self:match_preds(match, pattern, source) if not active then return iter() -- tail call: try next match end + + self:apply_directives(match, pattern, source, metadata) end - return pattern, match + return pattern, match, metadata end return iter end diff --git a/runtime/syntax/php.vim b/runtime/syntax/php.vim index 1c5c24e56b..30d13581c3 100644 --- a/runtime/syntax/php.vim +++ b/runtime/syntax/php.vim @@ -1,9 +1,11 @@ " Vim syntax file -" Language: php PHP 3/4/5/7 -" Maintainer: Jason Woofenden <jason@jasonwoof.com> -" Last Change: Jun 20, 2018 -" URL: https://jasonwoof.com/gitweb/?p=vim-syntax.git;a=blob;f=php.vim;hb=HEAD -" Former Maintainers: Peter Hodge <toomuchphp-vim@yahoo.com> +" Language: php PHP 3/4/5/7/8 +" Maintainer: Tyson Andre <tysonandre775@hotmail.com> +" Last Change: Sep 07, 2020 +" URL: https://github.com/TysonAndre/vim-syntax +" Former Maintainers: +" Jason Woofenden <jason@jasonwoof.com> +" Peter Hodge <toomuchphp-vim@yahoo.com> " Debian VIM Maintainers <pkg-vim-maintainers@lists.alioth.debian.org> " " Note: If you are using a colour terminal with dark background, you will @@ -107,7 +109,7 @@ syn keyword phpIntVar GLOBALS PHP_ERRMSG PHP_SELF HTTP_GET_VARS HTTP_POST_VARS H syn keyword phpCoreConstant PHP_VERSION PHP_OS DEFAULT_INCLUDE_PATH PEAR_INSTALL_DIR PEAR_EXTENSION_DIR PHP_EXTENSION_DIR PHP_BINDIR PHP_LIBDIR PHP_DATADIR PHP_SYSCONFDIR PHP_LOCALSTATEDIR PHP_CONFIG_FILE_PATH PHP_OUTPUT_HANDLER_START PHP_OUTPUT_HANDLER_CONT PHP_OUTPUT_HANDLER_END contained " Predefined constants -" Generated by: curl -q http://php.net/manual/en/errorfunc.constants.php | grep -oP 'E_\w+' | sort -u +" Generated by: curl -q https://www.php.net/manual/en/errorfunc.constants.php | grep -oP 'E_\w+' | sort -u syn keyword phpCoreConstant E_ALL E_COMPILE_ERROR E_COMPILE_WARNING E_CORE_ERROR E_CORE_WARNING E_DEPRECATED E_ERROR E_NOTICE E_PARSE E_RECOVERABLE_ERROR E_STRICT E_USER_DEPRECATED E_USER_ERROR E_USER_NOTICE E_USER_WARNING E_WARNING contained syn case ignore @@ -115,7 +117,10 @@ syn case ignore syn keyword phpConstant __LINE__ __FILE__ __FUNCTION__ __METHOD__ __CLASS__ __DIR__ __NAMESPACE__ __TRAIT__ contained -" Function and Methods ripped from php_manual_de.tar.gz Jan 2003 +" Function and Methods ripped from php_manual_de.tar.gz Jan 2003 and amended later with common bundled extensions + +syn keyword phpFunctions apc_cache_info apc_clear_cache apc_store apc_fetch apc_enabled apc_delete apc_add apc_sma_info apc_inc apc_dec apc_cas apc_exists contained +syn keyword phpFunctions apcu_add apcu_cache_info apcu_cas apcu_clear_cache apcu_dec apcu_delete apcu_enabled apcu_entry apcu_exists apcu_fetch apcu_inc apcu_key_info apcu_sma_info apcu_store contained syn keyword phpFunctions apache_child_terminate apache_get_modules apache_get_version apache_getenv apache_lookup_uri apache_note apache_request_headers apache_response_headers apache_setenv ascii2ebcdic ebcdic2ascii getallheaders virtual contained syn keyword phpFunctions array_change_key_case array_chunk array_column array_combine array_count_values array_diff_assoc array_diff_key array_diff_uassoc array_diff_ukey array_diff array_fill_keys array_fill array_filter array_flip array_intersect_assoc array_intersect_key array_intersect_uassoc array_intersect_ukey array_intersect array_key_exists array_keys array_map array_merge_recursive array_merge array_multisort array_pad array_pop array_product array_push array_rand array_reduce array_replace_recursive array_replace array_reverse array_search array_shift array_slice array_splice array_sum array_udiff_assoc array_udiff_uassoc array_udiff array_uintersect_assoc array_uintersect_uassoc array_uintersect array_unique array_unshift array_values array_walk_recursive array_walk arsort asort count current each end in_array key_exists key krsort ksort natcasesort natsort next pos prev range reset rsort shuffle sizeof sort uasort uksort usort contained syn keyword phpFunctions aspell_check aspell_new aspell_suggest contained @@ -128,10 +133,10 @@ syn keyword phpFunctions com VARIANT com_addref com_get com_invoke com_isenum co syn keyword phpFunctions cpdf_add_annotation cpdf_add_outline cpdf_arc cpdf_begin_text cpdf_circle cpdf_clip cpdf_close cpdf_closepath_fill_stroke cpdf_closepath_stroke cpdf_closepath cpdf_continue_text cpdf_curveto cpdf_end_text cpdf_fill_stroke cpdf_fill cpdf_finalize_page cpdf_finalize cpdf_global_set_document_limits cpdf_import_jpeg cpdf_lineto cpdf_moveto cpdf_newpath cpdf_open cpdf_output_buffer cpdf_page_init cpdf_place_inline_image cpdf_rect cpdf_restore cpdf_rlineto cpdf_rmoveto cpdf_rotate_text cpdf_rotate cpdf_save_to_file cpdf_save cpdf_scale cpdf_set_action_url cpdf_set_char_spacing cpdf_set_creator cpdf_set_current_page cpdf_set_font_directories cpdf_set_font_map_file cpdf_set_font cpdf_set_horiz_scaling cpdf_set_keywords cpdf_set_leading cpdf_set_page_animation cpdf_set_subject cpdf_set_text_matrix cpdf_set_text_pos cpdf_set_text_rendering cpdf_set_text_rise cpdf_set_title cpdf_set_viewer_preferences cpdf_set_word_spacing cpdf_setdash cpdf_setflat cpdf_setgray_fill cpdf_setgray_stroke cpdf_setgray cpdf_setlinecap cpdf_setlinejoin cpdf_setlinewidth cpdf_setmiterlimit cpdf_setrgbcolor_fill cpdf_setrgbcolor_stroke cpdf_setrgbcolor cpdf_show_xy cpdf_show cpdf_stringwidth cpdf_stroke cpdf_text cpdf_translate contained syn keyword phpFunctions crack_check crack_closedict crack_getlastmessage crack_opendict contained syn keyword phpFunctions ctype_alnum ctype_alpha ctype_cntrl ctype_digit ctype_graph ctype_lower ctype_print ctype_punct ctype_space ctype_upper ctype_xdigit contained -syn keyword phpFunctions curl_close curl_errno curl_error curl_exec curl_getinfo curl_init curl_multi_add_handle curl_multi_close curl_multi_exec curl_multi_getcontent curl_multi_info_read curl_multi_init curl_multi_remove_handle curl_multi_select curl_setopt curl_version contained +syn keyword phpFunctions curl_close curl_errno curl_error curl_exec curl_getinfo curl_init curl_multi_add_handle curl_multi_close curl_multi_exec curl_multi_getcontent curl_multi_info_read curl_multi_init curl_multi_remove_handle curl_multi_select curl_setopt curl_version curl_copy_handle curl_escape curl_file_create curl_multi_errno curl_multi_setopt curl_multi_strerror curl_pause curl_reset curl_setopt_array curl_share_close curl_share_errno curl_share_init curl_share_setopt curl_share_strerror curl_strerror curl_unescape contained syn keyword phpFunctions cybercash_base64_decode cybercash_base64_encode cybercash_decr cybercash_encr contained syn keyword phpFunctions cyrus_authenticate cyrus_bind cyrus_close cyrus_connect cyrus_query cyrus_unbind contained -syn keyword phpFunctions checkdate date getdate gettimeofday gmdate gmmktime gmstrftime localtime microtime mktime strftime strtotime time contained +syn keyword phpFunctions checkdate date getdate gettimeofday gmdate gmmktime gmstrftime localtime microtime mktime strftime strtotime time date_add date_create date_create_from_format date_create_immutable date_create_immutable_from_format date_date_set date_default_timezone_get date_default_timezone_set date_diff date_format date_get_last_errors date_interval_create_from_date_string date_interval_format date_isodate_set date_modify date_offset_get date_parse date_parse_from_format date_sub date_sun_info date_sunrise date_sunset date_time_set date_timestamp_get date_timestamp_set date_timezone_get date_timezone_set idate timezone_abbreviations_list timezone_identifiers_list timezone_location_get timezone_name_from_abbr timezone_name_get timezone_offset_get timezone_open timezone_transitions_get timezone_version_get contained syn keyword phpFunctions dba_close dba_delete dba_exists dba_fetch dba_firstkey dba_handlers dba_insert dba_key_split dba_list dba_nextkey dba_open dba_optimize dba_popen dba_replace dba_sync contained syn keyword phpFunctions dbase_add_record dbase_close dbase_create dbase_delete_record dbase_get_header_info dbase_get_record_with_names dbase_get_record dbase_numfields dbase_numrecords dbase_open dbase_pack dbase_replace_record contained syn keyword phpFunctions dblist dbmclose dbmdelete dbmexists dbmfetch dbmfirstkey dbminsert dbmnextkey dbmopen dbmreplace contained @@ -139,21 +144,25 @@ syn keyword phpFunctions dbplus_add dbplus_aql dbplus_chdir dbplus_close dbplus_ syn keyword phpFunctions dbx_close dbx_compare dbx_connect dbx_error dbx_escape_string dbx_fetch_row dbx_query dbx_sort contained syn keyword phpFunctions dio_close dio_fcntl dio_open dio_read dio_seek dio_stat dio_tcsetattr dio_truncate dio_write contained syn keyword phpFunctions chdir chroot dir closedir getcwd opendir readdir rewinddir scandir contained +syn keyword phpFunctions dom_import_simplexml contained syn keyword phpFunctions domxml_new_doc domxml_open_file domxml_open_mem domxml_version domxml_xmltree domxml_xslt_stylesheet_doc domxml_xslt_stylesheet_file domxml_xslt_stylesheet xpath_eval_expression xpath_eval xpath_new_context xptr_eval xptr_new_context contained syn keyword phpMethods name specified value create_attribute create_cdata_section create_comment create_element_ns create_element create_entity_reference create_processing_instruction create_text_node doctype document_element dump_file dump_mem get_element_by_id get_elements_by_tagname html_dump_mem xinclude entities internal_subset name notations public_id system_id get_attribute_node get_attribute get_elements_by_tagname has_attribute remove_attribute set_attribute tagname add_namespace append_child append_sibling attributes child_nodes clone_node dump_node first_child get_content has_attributes has_child_nodes insert_before is_blank_node last_child next_sibling node_name node_type node_value owner_document parent_node prefix previous_sibling remove_child replace_child replace_node set_content set_name set_namespace unlink_node data target process result_dump_file result_dump_mem contained syn keyword phpFunctions dotnet_load contained syn keyword phpFunctions debug_backtrace debug_print_backtrace error_log error_reporting restore_error_handler set_error_handler trigger_error user_error contained +syn keyword phpFunctions enchant_broker_describe enchant_broker_dict_exists enchant_broker_free enchant_broker_free_dict enchant_broker_get_dict_path enchant_broker_get_error enchant_broker_init enchant_broker_list_dicts enchant_broker_request_dict enchant_broker_request_pwl_dict enchant_broker_set_dict_path enchant_broker_set_ordering enchant_dict_add_to_personal enchant_dict_add_to_session enchant_dict_check enchant_dict_describe enchant_dict_get_error enchant_dict_is_in_session enchant_dict_quick_check enchant_dict_store_replacement enchant_dict_suggest contained syn keyword phpFunctions escapeshellarg escapeshellcmd exec passthru proc_close proc_get_status proc_nice proc_open proc_terminate shell_exec system contained syn keyword phpFunctions fam_cancel_monitor fam_close fam_monitor_collection fam_monitor_directory fam_monitor_file fam_next_event fam_open fam_pending fam_resume_monitor fam_suspend_monitor contained syn keyword phpFunctions fbsql_affected_rows fbsql_autocommit fbsql_change_user fbsql_close fbsql_commit fbsql_connect fbsql_create_blob fbsql_create_clob fbsql_create_db fbsql_data_seek fbsql_database_password fbsql_database fbsql_db_query fbsql_db_status fbsql_drop_db fbsql_errno fbsql_error fbsql_fetch_array fbsql_fetch_assoc fbsql_fetch_field fbsql_fetch_lengths fbsql_fetch_object fbsql_fetch_row fbsql_field_flags fbsql_field_len fbsql_field_name fbsql_field_seek fbsql_field_table fbsql_field_type fbsql_free_result fbsql_get_autostart_info fbsql_hostname fbsql_insert_id fbsql_list_dbs fbsql_list_fields fbsql_list_tables fbsql_next_result fbsql_num_fields fbsql_num_rows fbsql_password fbsql_pconnect fbsql_query fbsql_read_blob fbsql_read_clob fbsql_result fbsql_rollback fbsql_select_db fbsql_set_lob_mode fbsql_set_transaction fbsql_start_db fbsql_stop_db fbsql_tablename fbsql_username fbsql_warnings contained syn keyword phpFunctions fdf_add_doc_javascript fdf_add_template fdf_close fdf_create fdf_enum_values fdf_errno fdf_error fdf_get_ap fdf_get_attachment fdf_get_encoding fdf_get_file fdf_get_flags fdf_get_opt fdf_get_status fdf_get_value fdf_get_version fdf_header fdf_next_field_name fdf_open_string fdf_open fdf_remove_item fdf_save_string fdf_save fdf_set_ap fdf_set_encoding fdf_set_file fdf_set_flags fdf_set_javascript_action fdf_set_opt fdf_set_status fdf_set_submit_form_action fdf_set_target_frame fdf_set_value fdf_set_version contained syn keyword phpFunctions filepro_fieldcount filepro_fieldname filepro_fieldtype filepro_fieldwidth filepro_retrieve filepro_rowcount filepro contained +syn keyword phpFunctions filter_has_var filter_id filter_input filter_input_array filter_list filter_var filter_var_array contained syn keyword phpFunctions basename chgrp chmod chown clearstatcache copy delete dirname disk_free_space disk_total_space diskfreespace fclose feof fflush fgetc fgetcsv fgets fgetss file_exists file_get_contents file_put_contents file fileatime filectime filegroup fileinode filemtime fileowner fileperms filesize filetype flock fnmatch fopen fpassthru fputs fread fscanf fseek fstat ftell ftruncate fwrite glob is_dir is_executable is_file is_link is_readable is_uploaded_file is_writable is_writeable link linkinfo lstat mkdir move_uploaded_file parse_ini_file pathinfo pclose popen readfile readlink realpath rename rewind rmdir set_file_buffer stat symlink tempnam tmpfile touch umask unlink contained syn keyword phpFunctions fribidi_log2vis contained -syn keyword phpFunctions ftp_alloc ftp_cdup ftp_chdir ftp_chmod ftp_close ftp_connect ftp_delete ftp_exec ftp_fget ftp_fput ftp_get_option ftp_get ftp_login ftp_mdtm ftp_mkdir ftp_nb_continue ftp_nb_fget ftp_nb_fput ftp_nb_get ftp_nb_put ftp_nlist ftp_pasv ftp_put ftp_pwd ftp_quit ftp_raw ftp_rawlist ftp_rename ftp_rmdir ftp_set_option ftp_site ftp_size ftp_ssl_connect ftp_systype contained +syn keyword phpFunctions ftp_alloc ftp_cdup ftp_chdir ftp_chmod ftp_close ftp_connect ftp_delete ftp_exec ftp_fget ftp_fput ftp_get_option ftp_get ftp_login ftp_mdtm ftp_mkdir ftp_nb_continue ftp_nb_fget ftp_nb_fput ftp_nb_get ftp_nb_put ftp_nlist ftp_pasv ftp_put ftp_pwd ftp_quit ftp_raw ftp_rawlist ftp_rename ftp_rmdir ftp_set_option ftp_site ftp_size ftp_ssl_connect ftp_systype ftp_append ftp_mlsd contained syn keyword phpFunctions call_user_func_array call_user_func create_function func_get_arg func_get_args func_num_args function_exists get_defined_functions register_shutdown_function register_tick_function unregister_tick_function contained -syn keyword phpFunctions bind_textdomain_codeset bindtextdomain dcgettext dcngettext dgettext dngettext gettext ngettext textdomain contained -syn keyword phpFunctions gmp_abs gmp_add gmp_and gmp_clrbit gmp_cmp gmp_com gmp_div_q gmp_div_qr gmp_div_r gmp_div gmp_divexact gmp_fact gmp_gcd gmp_gcdext gmp_hamdist gmp_init gmp_intval gmp_invert gmp_jacobi gmp_legendre gmp_mod gmp_mul gmp_neg gmp_or gmp_perfect_square gmp_popcount gmp_pow gmp_powm gmp_prob_prime gmp_random gmp_scan0 gmp_scan1 gmp_setbit gmp_sign gmp_sqrt gmp_sqrtrem gmp_sqrtrm gmp_strval gmp_sub gmp_xor contained +syn keyword phpFunctions bind_textdomain_codeset bindtextdomain dcgettext dcngettext dgettext dngettext gettext ngettext textdomain _ contained +syn keyword phpFunctions gmp_abs gmp_add gmp_and gmp_clrbit gmp_cmp gmp_com gmp_div_q gmp_div_qr gmp_div_r gmp_div gmp_divexact gmp_fact gmp_gcd gmp_gcdext gmp_hamdist gmp_init gmp_intval gmp_invert gmp_jacobi gmp_legendre gmp_mod gmp_mul gmp_neg gmp_or gmp_perfect_square gmp_popcount gmp_pow gmp_powm gmp_prob_prime gmp_random gmp_scan0 gmp_scan1 gmp_setbit gmp_sign gmp_sqrt gmp_sqrtrem gmp_sqrtrm gmp_strval gmp_sub gmp_xor gmp_binomial gmp_export gmp_import gmp_kronecker gmp_lcm gmp_nextprime gmp_perfect_power gmp_random_bits gmp_random_range gmp_random_seed gmp_root gmp_rootrem gmp_testbit contained +syn keyword phpFunctions hash hash_algos hash_copy hash_equals hash_file hash_final hash_hkdf hash_hmac hash_hmac_algos hash_hmac_file hash_init hash_pbkdf2 hash_update hash_update_file hash_update_stream contained syn keyword phpFunctions header headers_list headers_sent setcookie contained syn keyword phpFunctions hw_api_attribute hwapi_hgcsp hw_api_content hw_api_object contained syn keyword phpMethods key langdepvalue value values checkin checkout children mimetype read content copy dbstat dcstat dstanchors dstofsrcanchors count reason find ftstat hwstat identify info insert insertanchor insertcollection insertdocument link lock move assign attreditable count insert remove title value object objectbyanchor parents description type remove replace setcommitedversion srcanchors srcsofdst unlock user userlist contained @@ -161,24 +170,29 @@ syn keyword phpFunctions hw_Array2Objrec hw_changeobject hw_Children hw_Children syn keyword phpFunctions ibase_add_user ibase_affected_rows ibase_blob_add ibase_blob_cancel ibase_blob_close ibase_blob_create ibase_blob_echo ibase_blob_get ibase_blob_import ibase_blob_info ibase_blob_open ibase_close ibase_commit_ret ibase_commit ibase_connect ibase_delete_user ibase_drop_db ibase_errcode ibase_errmsg ibase_execute ibase_fetch_assoc ibase_fetch_object ibase_fetch_row ibase_field_info ibase_free_event_handler ibase_free_query ibase_free_result ibase_gen_id ibase_modify_user ibase_name_result ibase_num_fields ibase_num_params ibase_param_info ibase_pconnect ibase_prepare ibase_query ibase_rollback_ret ibase_rollback ibase_set_event_handler ibase_timefmt ibase_trans ibase_wait_event contained syn keyword phpFunctions iconv_get_encoding iconv_mime_decode_headers iconv_mime_decode iconv_mime_encode iconv_set_encoding iconv_strlen iconv_strpos iconv_strrpos iconv_substr iconv ob_iconv_handler contained syn keyword phpFunctions ifx_affected_rows ifx_blobinfile_mode ifx_byteasvarchar ifx_close ifx_connect ifx_copy_blob ifx_create_blob ifx_create_char ifx_do ifx_error ifx_errormsg ifx_fetch_row ifx_fieldproperties ifx_fieldtypes ifx_free_blob ifx_free_char ifx_free_result ifx_get_blob ifx_get_char ifx_getsqlca ifx_htmltbl_result ifx_nullformat ifx_num_fields ifx_num_rows ifx_pconnect ifx_prepare ifx_query ifx_textasvarchar ifx_update_blob ifx_update_char ifxus_close_slob ifxus_create_slob ifxus_free_slob ifxus_open_slob ifxus_read_slob ifxus_seek_slob ifxus_tell_slob ifxus_write_slob contained -syn keyword phpFunctions exif_imagetype exif_read_data exif_thumbnail gd_info getimagesize image_type_to_mime_type image2wbmp imagealphablending imageantialias imagearc imagechar imagecharup imagecolorallocate imagecolorallocatealpha imagecolorat imagecolorclosest imagecolorclosestalpha imagecolorclosesthwb imagecolordeallocate imagecolorexact imagecolorexactalpha imagecolormatch imagecolorresolve imagecolorresolvealpha imagecolorset imagecolorsforindex imagecolorstotal imagecolortransparent imagecopy imagecopymerge imagecopymergegray imagecopyresampled imagecopyresized imagecreate imagecreatefromgd2 imagecreatefromgd2part imagecreatefromgd imagecreatefromgif imagecreatefromjpeg imagecreatefrompng imagecreatefromstring imagecreatefromwbmp imagecreatefromxbm imagecreatefromxpm imagecreatetruecolor imagedashedline imagedestroy imageellipse imagefill imagefilledarc imagefilledellipse imagefilledpolygon imagefilledrectangle imagefilltoborder imagefontheight imagefontwidth imageftbbox imagefttext imagegammacorrect imagegd2 imagegd imagegif imageinterlace imageistruecolor imagejpeg imageline imageloadfont imagepalettecopy imagepng imagepolygon imagepsbbox imagepscopyfont imagepsencodefont imagepsextendfont imagepsfreefont imagepsloadfont imagepsslantfont imagepstext imagerectangle imagerotate imagesavealpha imagesetbrush imagesetpixel imagesetstyle imagesetthickness imagesettile imagestring imagestringup imagesx imagesy imagetruecolortopalette imagettfbbox imagettftext imagetypes imagewbmp iptcembed iptcparse jpeg2wbmp png2wbmp read_exif_data contained +syn keyword phpFunctions igbinary_serialize igbinary_unserialize contained +syn keyword phpFunctions exif_imagetype exif_read_data exif_thumbnail gd_info getimagesize image_type_to_mime_type image2wbmp imagealphablending imageantialias imagearc imagechar imagecharup imagecolorallocate imagecolorallocatealpha imagecolorat imagecolorclosest imagecolorclosestalpha imagecolorclosesthwb imagecolordeallocate imagecolorexact imagecolorexactalpha imagecolormatch imagecolorresolve imagecolorresolvealpha imagecolorset imagecolorsforindex imagecolorstotal imagecolortransparent imagecopy imagecopymerge imagecopymergegray imagecopyresampled imagecopyresized imagecreate imagecreatefromgd2 imagecreatefromgd2part imagecreatefromgd imagecreatefromgif imagecreatefromjpeg imagecreatefrompng imagecreatefromstring imagecreatefromwbmp imagecreatefromxbm imagecreatefromxpm imagecreatetruecolor imagedashedline imagedestroy imageellipse imagefill imagefilledarc imagefilledellipse imagefilledpolygon imagefilledrectangle imagefilltoborder imagefontheight imagefontwidth imageftbbox imagefttext imagegammacorrect imagegd2 imagegd imagegif imageinterlace imageistruecolor imagejpeg imageline imageloadfont imagepalettecopy imagepng imagepolygon imagepsbbox imagepscopyfont imagepsencodefont imagepsextendfont imagepsfreefont imagepsloadfont imagepsslantfont imagepstext imagerectangle imagerotate imagesavealpha imagesetbrush imagesetpixel imagesetstyle imagesetthickness imagesettile imagestring imagestringup imagesx imagesy imagetruecolortopalette imagettfbbox imagettftext imagetypes imagewbmp iptcembed iptcparse jpeg2wbmp png2wbmp read_exif_data exif_tagname imageaffine imageaffinematrixconcat imageaffinematrixget imagebmp imageconvolution imagecreatefrombmp imagecreatefromtga imagecrop imagecropauto imagefilter imageflip imagegetclip imagelayereffect imageopenpolygon imagepalettetotruecolor imageresolution imagescale imagesetclip imagesetinterpolation imagexbm contained syn keyword phpFunctions imap_8bit imap_alerts imap_append imap_base64 imap_binary imap_body imap_bodystruct imap_check imap_clearflag_full imap_close imap_createmailbox imap_delete imap_deletemailbox imap_errors imap_expunge imap_fetch_overview imap_fetchbody imap_fetchheader imap_fetchstructure imap_get_quota imap_get_quotaroot imap_getacl imap_getmailboxes imap_getsubscribed imap_header imap_headerinfo imap_headers imap_last_error imap_list imap_listmailbox imap_listscan imap_listsubscribed imap_lsub imap_mail_compose imap_mail_copy imap_mail_move imap_mail imap_mailboxmsginfo imap_mime_header_decode imap_msgno imap_num_msg imap_num_recent imap_open imap_ping imap_qprint imap_renamemailbox imap_reopen imap_rfc822_parse_adrlist imap_rfc822_parse_headers imap_rfc822_write_address imap_scanmailbox imap_search imap_set_quota imap_setacl imap_setflag_full imap_sort imap_status imap_subscribe imap_thread imap_timeout imap_uid imap_undelete imap_unsubscribe imap_utf7_decode imap_utf7_encode imap_utf8 contained syn keyword phpFunctions assert_options assert dl extension_loaded get_cfg_var get_current_user get_defined_constants get_extension_funcs get_include_path get_included_files get_loaded_extensions get_magic_quotes_gpc get_magic_quotes_runtime get_required_files getenv getlastmod getmygid getmyinode getmypid getmyuid getopt getrusage ini_alter ini_get_all ini_get ini_restore ini_set main memory_get_usage php_ini_scanned_files php_logo_guid php_sapi_name php_uname phpcredits phpinfo phpversion putenv restore_include_path set_include_path set_magic_quotes_runtime set_time_limit version_compare zend_logo_guid zend_version contained syn keyword phpFunctions ingres_autocommit ingres_close ingres_commit ingres_connect ingres_fetch_array ingres_fetch_object ingres_fetch_row ingres_field_length ingres_field_name ingres_field_nullable ingres_field_precision ingres_field_scale ingres_field_type ingres_num_fields ingres_num_rows ingres_pconnect ingres_query ingres_rollback contained +syn keyword phpFunctions collator_asort collator_compare collator_create collator_get_attribute collator_get_error_code collator_get_error_message collator_get_locale collator_get_sort_key collator_get_strength collator_set_attribute collator_set_strength collator_sort collator_sort_with_sort_keys datefmt_create datefmt_format datefmt_format_object datefmt_get_calendar datefmt_get_calendar_object datefmt_get_datetype datefmt_get_error_code datefmt_get_error_message datefmt_get_locale datefmt_get_pattern datefmt_get_timetype datefmt_get_timezone datefmt_get_timezone_id datefmt_is_lenient datefmt_localtime datefmt_parse datefmt_set_calendar datefmt_set_lenient datefmt_set_pattern datefmt_set_timezone grapheme_extract grapheme_stripos grapheme_stristr grapheme_strlen grapheme_strpos grapheme_strripos grapheme_strrpos grapheme_strstr grapheme_substr idn_to_ascii idn_to_utf8 intl_error_name intl_get_error_code intl_get_error_message intl_is_failure intlcal_add intlcal_after intlcal_before intlcal_clear intlcal_create_instance intlcal_equals intlcal_field_difference intlcal_from_date_time intlcal_get intlcal_get_actual_maximum intlcal_get_actual_minimum intlcal_get_available_locales intlcal_get_day_of_week_type intlcal_get_error_code intlcal_get_error_message intlcal_get_first_day_of_week intlcal_get_greatest_minimum intlcal_get_keyword_values_for_locale intlcal_get_least_maximum intlcal_get_locale intlcal_get_maximum intlcal_get_minimal_days_in_first_week intlcal_get_minimum intlcal_get_now intlcal_get_repeated_wall_time_option intlcal_get_skipped_wall_time_option intlcal_get_time intlcal_get_time_zone intlcal_get_type intlcal_get_weekend_transition intlcal_in_daylight_time intlcal_is_equivalent_to intlcal_is_lenient intlcal_is_set intlcal_is_weekend intlcal_roll intlcal_set intlcal_set_first_day_of_week intlcal_set_lenient intlcal_set_minimal_days_in_first_week intlcal_set_repeated_wall_time_option intlcal_set_skipped_wall_time_option intlcal_set_time intlcal_set_time_zone intlcal_to_date_time intlgregcal_create_instance intlgregcal_get_gregorian_change intlgregcal_is_leap_year intlgregcal_set_gregorian_change intltz_count_equivalent_ids intltz_create_default intltz_create_enumeration intltz_create_time_zone intltz_create_time_zone_id_enumeration intltz_from_date_time_zone intltz_get_canonical_id intltz_get_display_name intltz_get_dst_savings intltz_get_equivalent_id intltz_get_error_code intltz_get_error_message intltz_get_gmt intltz_get_id intltz_get_offset intltz_get_raw_offset intltz_get_region intltz_get_tz_data_version intltz_get_unknown intltz_has_same_rules intltz_to_date_time_zone intltz_use_daylight_time locale_accept_from_http locale_canonicalize locale_compose locale_filter_matches locale_get_all_variants locale_get_default locale_get_display_language locale_get_display_name locale_get_display_region locale_get_display_script locale_get_display_variant locale_get_keywords locale_get_primary_language locale_get_region locale_get_script locale_lookup locale_parse locale_set_default msgfmt_create msgfmt_format msgfmt_format_message msgfmt_get_error_code msgfmt_get_error_message msgfmt_get_locale msgfmt_get_pattern msgfmt_parse msgfmt_parse_message msgfmt_set_pattern normalizer_is_normalized normalizer_normalize numfmt_create numfmt_format numfmt_format_currency numfmt_get_attribute numfmt_get_error_code numfmt_get_error_message numfmt_get_locale numfmt_get_pattern numfmt_get_symbol numfmt_get_text_attribute numfmt_parse numfmt_parse_currency numfmt_set_attribute numfmt_set_pattern numfmt_set_symbol numfmt_set_text_attribute resourcebundle_count resourcebundle_create resourcebundle_get resourcebundle_get_error_code resourcebundle_get_error_message resourcebundle_locales transliterator_create transliterator_create_from_rules transliterator_create_inverse transliterator_get_error_code transliterator_get_error_message transliterator_list_ids transliterator_transliterate contained syn keyword phpFunctions ircg_channel_mode ircg_disconnect ircg_fetch_error_msg ircg_get_username ircg_html_encode ircg_ignore_add ircg_ignore_del ircg_is_conn_alive ircg_join ircg_kick ircg_lookup_format_messages ircg_msg ircg_nick ircg_nickname_escape ircg_nickname_unescape ircg_notice ircg_part ircg_pconnect ircg_register_format_messages ircg_set_current ircg_set_file ircg_set_on_die ircg_topic ircg_whois contained syn keyword phpFunctions java_last_exception_clear java_last_exception_get contained -syn keyword phpFunctions json_decode json_encode json_last_error contained +syn keyword phpFunctions json_decode json_encode json_last_error json_last_error_msg contained syn keyword phpFunctions ldap_8859_to_t61 ldap_add ldap_bind ldap_close ldap_compare ldap_connect ldap_count_entries ldap_delete ldap_dn2ufn ldap_err2str ldap_errno ldap_error ldap_explode_dn ldap_first_attribute ldap_first_entry ldap_first_reference ldap_free_result ldap_get_attributes ldap_get_dn ldap_get_entries ldap_get_option ldap_get_values_len ldap_get_values ldap_list ldap_mod_add ldap_mod_del ldap_mod_replace ldap_modify ldap_next_attribute ldap_next_entry ldap_next_reference ldap_parse_reference ldap_parse_result ldap_read ldap_rename ldap_search ldap_set_option ldap_set_rebind_proc ldap_sort ldap_start_tls ldap_t61_to_8859 ldap_unbind contained +syn keyword phpFunctions libxml_clear_errors libxml_disable_entity_loader libxml_get_errors libxml_get_last_error libxml_set_external_entity_loader libxml_set_streams_context libxml_use_internal_errors contained syn keyword phpFunctions lzf_compress lzf_decompress lzf_optimized_for contained syn keyword phpFunctions ezmlm_hash mail contained syn keyword phpFunctions mailparse_determine_best_xfer_encoding mailparse_msg_create mailparse_msg_extract_part_file mailparse_msg_extract_part mailparse_msg_free mailparse_msg_get_part_data mailparse_msg_get_part mailparse_msg_get_structure mailparse_msg_parse_file mailparse_msg_parse mailparse_rfc822_parse_addresses mailparse_stream_encode mailparse_uudecode_all contained syn keyword phpFunctions abs acos acosh asin asinh atan2 atan atanh base_convert bindec ceil cos cosh decbin dechex decoct deg2rad exp expm1 floor fmod getrandmax hexdec hypot is_finite is_infinite is_nan lcg_value log10 log1p log max min mt_getrandmax mt_rand mt_srand octdec pi pow rad2deg rand round sin sinh sqrt srand tan tanh contained -syn keyword phpFunctions mb_convert_case mb_convert_encoding mb_convert_kana mb_convert_variables mb_decode_mimeheader mb_decode_numericentity mb_detect_encoding mb_detect_order mb_encode_mimeheader mb_encode_numericentity mb_ereg_match mb_ereg_replace mb_ereg_search_getpos mb_ereg_search_getregs mb_ereg_search_init mb_ereg_search_pos mb_ereg_search_regs mb_ereg_search_setpos mb_ereg_search mb_ereg mb_eregi_replace mb_eregi mb_get_info mb_http_input mb_http_output mb_internal_encoding mb_language mb_output_handler mb_parse_str mb_preferred_mime_name mb_regex_encoding mb_regex_set_options mb_send_mail mb_split mb_strcut mb_strimwidth mb_strlen mb_strpos mb_strrpos mb_strtolower mb_strtoupper mb_strwidth mb_substitute_character mb_substr_count mb_substr contained +syn keyword phpFunctions array_key_first array_key_last boolval cli_get_process_title cli_set_process_title convert_uudecode convert_uuencode debug_zval_dump error_clear_last error_get_last forward_static_call forward_static_call_array fputcsv get_headers gethostname getimagesizefromstring header_register_callback header_remove hex2bin hrtime htmlspecialchars_decode http_response_code image_type_to_extension inet_ntop inet_pton intdiv is_countable is_iterable lcfirst lchgrp lchown memory_get_peak_usage net_get_interfaces parse_ini_string password_algos password_get_info password_hash password_needs_rehash password_verify php_ini_loaded_file php_strip_whitespace quoted_printable_encode random_bytes random_int realpath_cache_get realpath_cache_size setrawcookie str_getcsv stream_bucket_append stream_bucket_make_writeable stream_bucket_new stream_bucket_prepend stream_context_get_default stream_context_get_params stream_context_set_default stream_filter_remove stream_is_local stream_isatty stream_resolve_include_path stream_set_chunk_size stream_set_read_buffer stream_socket_enable_crypto stream_socket_pair stream_socket_shutdown stream_supports_lock stream_wrapper_restore stream_wrapper_unregister strpbrk strptime sys_get_temp_dir sys_getloadavg time_nanosleep time_sleep_until vfprintf contained + +syn keyword phpFunctions mb_convert_case mb_convert_encoding mb_convert_kana mb_convert_variables mb_decode_mimeheader mb_decode_numericentity mb_detect_encoding mb_detect_order mb_encode_mimeheader mb_encode_numericentity mb_ereg_match mb_ereg_replace mb_ereg_search_getpos mb_ereg_search_getregs mb_ereg_search_init mb_ereg_search_pos mb_ereg_search_regs mb_ereg_search_setpos mb_ereg_search mb_ereg mb_eregi_replace mb_eregi mb_get_info mb_http_input mb_http_output mb_internal_encoding mb_language mb_output_handler mb_parse_str mb_preferred_mime_name mb_regex_encoding mb_regex_set_options mb_send_mail mb_split mb_strcut mb_strimwidth mb_strlen mb_strpos mb_strrpos mb_strtolower mb_strtoupper mb_strwidth mb_substitute_character mb_substr_count mb_substr mb_check_encoding mb_chr mb_encoding_aliases mb_ereg_replace_callback mb_list_encodings mb_ord mb_scrub mb_str_split mb_stripos mb_stristr mb_strrchr mb_strrichr mb_strripos mb_strstr mbereg mbereg_match mbereg_replace mbereg_search mbereg_search_getpos mbereg_search_getregs mbereg_search_init mbereg_search_pos mbereg_search_regs mbereg_search_setpos mberegi mberegi_replace mbregex_encoding mbsplit contained syn keyword phpFunctions mcal_append_event mcal_close mcal_create_calendar mcal_date_compare mcal_date_valid mcal_day_of_week mcal_day_of_year mcal_days_in_month mcal_delete_calendar mcal_delete_event mcal_event_add_attribute mcal_event_init mcal_event_set_alarm mcal_event_set_category mcal_event_set_class mcal_event_set_description mcal_event_set_end mcal_event_set_recur_daily mcal_event_set_recur_monthly_mday mcal_event_set_recur_monthly_wday mcal_event_set_recur_none mcal_event_set_recur_weekly mcal_event_set_recur_yearly mcal_event_set_start mcal_event_set_title mcal_expunge mcal_fetch_current_stream_event mcal_fetch_event mcal_is_leap_year mcal_list_alarms mcal_list_events mcal_next_recurrence mcal_open mcal_popen mcal_rename_calendar mcal_reopen mcal_snooze mcal_store_event mcal_time_valid mcal_week_of_year contained syn keyword phpFunctions mcrypt_cbc mcrypt_cfb mcrypt_create_iv mcrypt_decrypt mcrypt_ecb mcrypt_enc_get_algorithms_name mcrypt_enc_get_block_size mcrypt_enc_get_iv_size mcrypt_enc_get_key_size mcrypt_enc_get_modes_name mcrypt_enc_get_supported_key_sizes mcrypt_enc_is_block_algorithm_mode mcrypt_enc_is_block_algorithm mcrypt_enc_is_block_mode mcrypt_enc_self_test mcrypt_encrypt mcrypt_generic_deinit mcrypt_generic_end mcrypt_generic_init mcrypt_generic mcrypt_get_block_size mcrypt_get_cipher_name mcrypt_get_iv_size mcrypt_get_key_size mcrypt_list_algorithms mcrypt_list_modes mcrypt_module_close mcrypt_module_get_algo_block_size mcrypt_module_get_algo_key_size mcrypt_module_get_supported_key_sizes mcrypt_module_is_block_algorithm_mode mcrypt_module_is_block_algorithm mcrypt_module_is_block_mode mcrypt_module_open mcrypt_module_self_test mcrypt_ofb mdecrypt_generic contained syn keyword phpFunctions mcve_adduser mcve_adduserarg mcve_bt mcve_checkstatus mcve_chkpwd mcve_chngpwd mcve_completeauthorizations mcve_connect mcve_connectionerror mcve_deleteresponse mcve_deletetrans mcve_deleteusersetup mcve_deluser mcve_destroyconn mcve_destroyengine mcve_disableuser mcve_edituser mcve_enableuser mcve_force mcve_getcell mcve_getcellbynum mcve_getcommadelimited mcve_getheader mcve_getuserarg mcve_getuserparam mcve_gft mcve_gl mcve_gut mcve_initconn mcve_initengine mcve_initusersetup mcve_iscommadelimited mcve_liststats mcve_listusers mcve_maxconntimeout mcve_monitor mcve_numcolumns mcve_numrows mcve_override mcve_parsecommadelimited mcve_ping mcve_preauth mcve_preauthcompletion mcve_qc mcve_responseparam mcve_return mcve_returncode mcve_returnstatus mcve_sale mcve_setblocking mcve_setdropfile mcve_setip mcve_setssl_files mcve_setssl mcve_settimeout mcve_settle mcve_text_avs mcve_text_code mcve_text_cv mcve_transactionauth mcve_transactionavs mcve_transactionbatch mcve_transactioncv mcve_transactionid mcve_transactionitem mcve_transactionssent mcve_transactiontext mcve_transinqueue mcve_transnew mcve_transparam mcve_transsend mcve_ub mcve_uwait mcve_verifyconnection mcve_verifysslcert mcve_void contained syn keyword phpFunctions mhash_count mhash_get_block_size mhash_get_hash_name mhash_keygen_s2k mhash contained -syn keyword phpFunctions mime_content_type contained +syn keyword phpFunctions mime_content_type finfo_buffer finfo_close finfo_file finfo_open finfo_set_flags contained syn keyword phpFunctions ming_setcubicthreshold ming_setscale ming_useswfversion SWFAction SWFBitmap swfbutton_keypress SWFbutton SWFDisplayItem SWFFill SWFFont SWFGradient SWFMorph SWFMovie SWFShape SWFSprite SWFText SWFTextField contained syn keyword phpMethods getHeight getWidth addAction addShape setAction setdown setHit setOver setUp addColor move moveTo multColor remove Rotate rotateTo scale scaleTo setDepth setName setRatio skewX skewXTo skewY skewYTo moveTo rotateTo scaleTo skewXTo skewYTo getwidth addEntry getshape1 getshape2 add nextframe output remove save setbackground setdimension setframes setrate streammp3 addFill drawCurve drawCurveTo drawLine drawLineTo movePen movePenTo setLeftFill setLine setRightFill add nextframe remove setframes addString getWidth moveTo setColor setFont setHeight setSpacing addstring align setbounds setcolor setFont setHeight setindentation setLeftMargin setLineSpacing setMargins setname setrightMargin contained syn keyword phpFunctions connection_aborted connection_status connection_timeout constant define defined die eval exit get_browser highlight_file highlight_string ignore_user_abort pack show_source sleep uniqid unpack usleep contained @@ -188,7 +202,7 @@ syn keyword phpFunctions msql_affected_rows msql_close msql_connect msql_create_ syn keyword phpFunctions mssql_bind mssql_close mssql_connect mssql_data_seek mssql_execute mssql_fetch_array mssql_fetch_assoc mssql_fetch_batch mssql_fetch_field mssql_fetch_object mssql_fetch_row mssql_field_length mssql_field_name mssql_field_seek mssql_field_type mssql_free_result mssql_free_statement mssql_get_last_message mssql_guid_string mssql_init mssql_min_error_severity mssql_min_message_severity mssql_next_result mssql_num_fields mssql_num_rows mssql_pconnect mssql_query mssql_result mssql_rows_affected mssql_select_db contained syn keyword phpFunctions muscat_close muscat_get muscat_give muscat_setup_net muscat_setup contained syn keyword phpFunctions mysql_affected_rows mysql_change_user mysql_client_encoding mysql_close mysql_connect mysql_create_db mysql_data_seek mysql_db_name mysql_db_query mysql_drop_db mysql_errno mysql_error mysql_escape_string mysql_fetch_array mysql_fetch_assoc mysql_fetch_field mysql_fetch_lengths mysql_fetch_object mysql_fetch_row mysql_field_flags mysql_field_len mysql_field_name mysql_field_seek mysql_field_table mysql_field_type mysql_free_result mysql_get_client_info mysql_get_host_info mysql_get_proto_info mysql_get_server_info mysql_info mysql_insert_id mysql_list_dbs mysql_list_fields mysql_list_processes mysql_list_tables mysql_num_fields mysql_num_rows mysql_pconnect mysql_ping mysql_query mysql_real_escape_string mysql_result mysql_select_db mysql_stat mysql_tablename mysql_thread_id mysql_unbuffered_query contained -syn keyword phpFunctions mysqli_affected_rows mysqli_autocommit mysqli_bind_param mysqli_bind_result mysqli_change_user mysqli_character_set_name mysqli_close mysqli_commit mysqli_connect mysqli_data_seek mysqli_debug mysqli_disable_reads_from_master mysqli_disable_rpl_parse mysqli_dump_debug_info mysqli_enable_reads_from_master mysqli_enable_rpl_parse mysqli_errno mysqli_error mysqli_execute mysqli_fetch_array mysqli_fetch_assoc mysqli_fetch_field_direct mysqli_fetch_field mysqli_fetch_fields mysqli_fetch_lengths mysqli_fetch_object mysqli_fetch_row mysqli_fetch mysqli_field_count mysqli_field_seek mysqli_field_tell mysqli_free_result mysqli_get_client_info mysqli_get_host_info mysqli_get_proto_info mysqli_get_server_info mysqli_get_server_version mysqli_info mysqli_init mysqli_insert_id mysqli_kill mysqli_master_query mysqli_num_fields mysqli_num_rows mysqli_options mysqli_param_count mysqli_ping mysqli_prepare_result mysqli_prepare mysqli_profiler mysqli_query mysqli_read_query_result mysqli_real_connect mysqli_real_escape_string mysqli_real_query mysqli_reload mysqli_rollback mysqli_rpl_parse_enabled mysqli_rpl_probe mysqli_rpl_query_type mysqli_select_db mysqli_send_long_data mysqli_send_query mysqli_slave_query mysqli_ssl_set mysqli_stat mysqli_stmt_affected_rows mysqli_stmt_close mysqli_stmt_errno mysqli_stmt_error mysqli_stmt_store_result mysqli_store_result mysqli_thread_id mysqli_thread_safe mysqli_use_result mysqli_warning_count contained +syn keyword phpFunctions mysqli_affected_rows mysqli_autocommit mysqli_bind_param mysqli_bind_result mysqli_change_user mysqli_character_set_name mysqli_close mysqli_commit mysqli_connect mysqli_data_seek mysqli_debug mysqli_disable_reads_from_master mysqli_disable_rpl_parse mysqli_dump_debug_info mysqli_enable_reads_from_master mysqli_enable_rpl_parse mysqli_errno mysqli_error mysqli_execute mysqli_fetch_array mysqli_fetch_assoc mysqli_fetch_field_direct mysqli_fetch_field mysqli_fetch_fields mysqli_fetch_lengths mysqli_fetch_object mysqli_fetch_row mysqli_fetch mysqli_field_count mysqli_field_seek mysqli_field_tell mysqli_free_result mysqli_get_client_info mysqli_get_host_info mysqli_get_proto_info mysqli_get_server_info mysqli_get_server_version mysqli_info mysqli_init mysqli_insert_id mysqli_kill mysqli_master_query mysqli_num_fields mysqli_num_rows mysqli_options mysqli_param_count mysqli_ping mysqli_prepare_result mysqli_prepare mysqli_profiler mysqli_query mysqli_read_query_result mysqli_real_connect mysqli_real_escape_string mysqli_real_query mysqli_reload mysqli_rollback mysqli_rpl_parse_enabled mysqli_rpl_probe mysqli_rpl_query_type mysqli_select_db mysqli_send_long_data mysqli_send_query mysqli_slave_query mysqli_ssl_set mysqli_stat mysqli_stmt_affected_rows mysqli_stmt_close mysqli_stmt_errno mysqli_stmt_error mysqli_stmt_store_result mysqli_store_result mysqli_thread_id mysqli_thread_safe mysqli_use_result mysqli_warning_count mysqli_begin_transaction mysqli_connect_errno mysqli_connect_error mysqli_error_list mysqli_escape_string mysqli_fetch_all mysqli_get_charset mysqli_get_client_stats mysqli_get_client_version mysqli_get_connection_stats mysqli_get_links_stats mysqli_get_warnings mysqli_more_results mysqli_multi_query mysqli_next_result mysqli_poll mysqli_reap_async_query mysqli_refresh mysqli_release_savepoint mysqli_report mysqli_savepoint mysqli_set_charset mysqli_set_opt mysqli_sqlstate mysqli_stmt_attr_get mysqli_stmt_attr_set mysqli_stmt_bind_param mysqli_stmt_bind_result mysqli_stmt_data_seek mysqli_stmt_error_list mysqli_stmt_execute mysqli_stmt_fetch mysqli_stmt_field_count mysqli_stmt_free_result mysqli_stmt_get_result mysqli_stmt_get_warnings mysqli_stmt_init mysqli_stmt_insert_id mysqli_stmt_more_results mysqli_stmt_next_result mysqli_stmt_num_rows mysqli_stmt_param_count mysqli_stmt_prepare mysqli_stmt_reset mysqli_stmt_result_metadata mysqli_stmt_send_long_data mysqli_stmt_sqlstate contained syn keyword phpFunctions ncurses_addch ncurses_addchnstr ncurses_addchstr ncurses_addnstr ncurses_addstr ncurses_assume_default_colors ncurses_attroff ncurses_attron ncurses_attrset ncurses_baudrate ncurses_beep ncurses_bkgd ncurses_bkgdset ncurses_border ncurses_bottom_panel ncurses_can_change_color ncurses_cbreak ncurses_clear ncurses_clrtobot ncurses_clrtoeol ncurses_color_content ncurses_color_set ncurses_curs_set ncurses_def_prog_mode ncurses_def_shell_mode ncurses_define_key ncurses_del_panel ncurses_delay_output ncurses_delch ncurses_deleteln ncurses_delwin ncurses_doupdate ncurses_echo ncurses_echochar ncurses_end ncurses_erase ncurses_erasechar ncurses_filter ncurses_flash ncurses_flushinp ncurses_getch ncurses_getmaxyx ncurses_getmouse ncurses_getyx ncurses_halfdelay ncurses_has_colors ncurses_has_ic ncurses_has_il ncurses_has_key ncurses_hide_panel ncurses_hline ncurses_inch ncurses_init_color ncurses_init_pair ncurses_init ncurses_insch ncurses_insdelln ncurses_insertln ncurses_insstr ncurses_instr ncurses_isendwin ncurses_keyok ncurses_keypad ncurses_killchar ncurses_longname ncurses_meta ncurses_mouse_trafo ncurses_mouseinterval ncurses_mousemask ncurses_move_panel ncurses_move ncurses_mvaddch ncurses_mvaddchnstr ncurses_mvaddchstr ncurses_mvaddnstr ncurses_mvaddstr ncurses_mvcur ncurses_mvdelch ncurses_mvgetch ncurses_mvhline ncurses_mvinch ncurses_mvvline ncurses_mvwaddstr ncurses_napms ncurses_new_panel ncurses_newpad ncurses_newwin ncurses_nl ncurses_nocbreak ncurses_noecho ncurses_nonl ncurses_noqiflush ncurses_noraw ncurses_pair_content ncurses_panel_above ncurses_panel_below ncurses_panel_window ncurses_pnoutrefresh ncurses_prefresh ncurses_putp ncurses_qiflush ncurses_raw ncurses_refresh ncurses_replace_panel ncurses_reset_prog_mode ncurses_reset_shell_mode ncurses_resetty ncurses_savetty ncurses_scr_dump ncurses_scr_init ncurses_scr_restore ncurses_scr_set ncurses_scrl ncurses_show_panel ncurses_slk_attr ncurses_slk_attroff ncurses_slk_attron ncurses_slk_attrset ncurses_slk_clear ncurses_slk_color ncurses_slk_init ncurses_slk_noutrefresh ncurses_slk_refresh ncurses_slk_restore ncurses_slk_set ncurses_slk_touch ncurses_standend ncurses_standout ncurses_start_color ncurses_termattrs ncurses_termname ncurses_timeout ncurses_top_panel ncurses_typeahead ncurses_ungetch ncurses_ungetmouse ncurses_update_panels ncurses_use_default_colors ncurses_use_env ncurses_use_extended_names ncurses_vidattr ncurses_vline ncurses_waddch ncurses_waddstr ncurses_wattroff ncurses_wattron ncurses_wattrset ncurses_wborder ncurses_wclear ncurses_wcolor_set ncurses_werase ncurses_wgetch ncurses_whline ncurses_wmouse_trafo ncurses_wmove ncurses_wnoutrefresh ncurses_wrefresh ncurses_wstandend ncurses_wstandout ncurses_wvline contained syn keyword phpFunctions checkdnsrr closelog debugger_off debugger_on define_syslog_variables dns_check_record dns_get_mx dns_get_record fsockopen gethostbyaddr gethostbyname gethostbynamel getmxrr getprotobyname getprotobynumber getservbyname getservbyport ip2long long2ip openlog pfsockopen socket_get_status socket_set_blocking socket_set_timeout syslog contained syn keyword phpFunctions yp_all yp_cat yp_err_string yp_errno yp_first yp_get_default_domain yp_master yp_match yp_next yp_order contained @@ -197,48 +211,55 @@ syn keyword phpFunctions nsapi_request_headers nsapi_response_headers nsapi_virt syn keyword phpFunctions aggregate_info aggregate_methods_by_list aggregate_methods_by_regexp aggregate_methods aggregate_properties_by_list aggregate_properties_by_regexp aggregate_properties aggregate aggregation_info deaggregate contained syn keyword phpFunctions ocibindbyname ocicancel ocicloselob ocicollappend ocicollassign ocicollassignelem ocicollgetelem ocicollmax ocicollsize ocicolltrim ocicolumnisnull ocicolumnname ocicolumnprecision ocicolumnscale ocicolumnsize ocicolumntype ocicolumntyperaw ocicommit ocidefinebyname ocierror ociexecute ocifetch ocifetchinto ocifetchstatement ocifreecollection ocifreecursor ocifreedesc ocifreestatement ociinternaldebug ociloadlob ocilogoff ocilogon ocinewcollection ocinewcursor ocinewdescriptor ocinlogon ocinumcols ociparse ociplogon ociresult ocirollback ocirowcount ocisavelob ocisavelobfile ociserverversion ocisetprefetch ocistatementtype ociwritelobtofile ociwritetemporarylob contained syn keyword phpFunctions odbc_autocommit odbc_binmode odbc_close_all odbc_close odbc_columnprivileges odbc_columns odbc_commit odbc_connect odbc_cursor odbc_data_source odbc_do odbc_error odbc_errormsg odbc_exec odbc_execute odbc_fetch_array odbc_fetch_into odbc_fetch_object odbc_fetch_row odbc_field_len odbc_field_name odbc_field_num odbc_field_precision odbc_field_scale odbc_field_type odbc_foreignkeys odbc_free_result odbc_gettypeinfo odbc_longreadlen odbc_next_result odbc_num_fields odbc_num_rows odbc_pconnect odbc_prepare odbc_primarykeys odbc_procedurecolumns odbc_procedures odbc_result_all odbc_result odbc_rollback odbc_setoption odbc_specialcolumns odbc_statistics odbc_tableprivileges odbc_tables contained -syn keyword phpFunctions openssl_cipher_iv_length openssl_csr_export_to_file openssl_csr_export openssl_csr_get_public_key openssl_csr_get_subject openssl_csr_new openssl_csr_sign openssl_decrypt openssl_dh_compute_key openssl_digest openssl_encrypt openssl_error_string openssl_free_key openssl_get_cert_locations openssl_get_cipher_methods openssl_get_md_methods openssl_get_privatekey openssl_get_publickey openssl_open openssl_pbkdf2 openssl_pkcs12_export_to_file openssl_pkcs12_export openssl_pkcs12_read openssl_pkcs7_decrypt openssl_pkcs7_encrypt openssl_pkcs7_sign openssl_pkcs7_verify openssl_pkey_export_to_file openssl_pkey_export openssl_pkey_free openssl_pkey_get_details openssl_pkey_get_private openssl_pkey_get_public openssl_pkey_new openssl_private_decrypt openssl_private_encrypt openssl_public_decrypt openssl_public_encrypt openssl_random_pseudo_bytes openssl_seal openssl_sign openssl_spki_export_challenge openssl_spki_export openssl_spki_new openssl_spki_verify openssl_verify openssl_x509_check_private_key openssl_x509_checkpurpose openssl_x509_export_to_file openssl_x509_export openssl_x509_fingerprint openssl_x509_free openssl_x509_parse openssl_x509_read contained +syn keyword phpFunctions opcache_reset opcache_invalidate opcache_compile_file opcache_is_script_cached opcache_get_configuration opcache_get_status contained +syn keyword phpFunctions openssl_cipher_iv_length openssl_csr_export_to_file openssl_csr_export openssl_csr_get_public_key openssl_csr_get_subject openssl_csr_new openssl_csr_sign openssl_decrypt openssl_dh_compute_key openssl_digest openssl_encrypt openssl_error_string openssl_free_key openssl_get_cert_locations openssl_get_cipher_methods openssl_get_md_methods openssl_get_privatekey openssl_get_publickey openssl_open openssl_pbkdf2 openssl_pkcs12_export_to_file openssl_pkcs12_export openssl_pkcs12_read openssl_pkcs7_decrypt openssl_pkcs7_encrypt openssl_pkcs7_sign openssl_pkcs7_verify openssl_pkey_export_to_file openssl_pkey_export openssl_pkey_free openssl_pkey_get_details openssl_pkey_get_private openssl_pkey_get_public openssl_pkey_new openssl_private_decrypt openssl_private_encrypt openssl_public_decrypt openssl_public_encrypt openssl_random_pseudo_bytes openssl_seal openssl_sign openssl_spki_export_challenge openssl_spki_export openssl_spki_new openssl_spki_verify openssl_verify openssl_x509_check_private_key openssl_x509_checkpurpose openssl_x509_export_to_file openssl_x509_export openssl_x509_fingerprint openssl_x509_free openssl_x509_parse openssl_x509_read openssl_get_curve_names openssl_pkcs7_read openssl_pkey_derive openssl_x509_verify contained syn keyword phpFunctions ora_bind ora_close ora_columnname ora_columnsize ora_columntype ora_commit ora_commitoff ora_commiton ora_do ora_error ora_errorcode ora_exec ora_fetch_into ora_fetch ora_getcolumn ora_logoff ora_logon ora_numcols ora_numrows ora_open ora_parse ora_plogon ora_rollback contained syn keyword phpFunctions flush ob_clean ob_end_clean ob_end_flush ob_flush ob_get_clean ob_get_contents ob_get_flush ob_get_length ob_get_level ob_get_status ob_gzhandler ob_implicit_flush ob_list_handlers ob_start output_add_rewrite_var output_reset_rewrite_vars contained syn keyword phpFunctions overload contained syn keyword phpFunctions ovrimos_close ovrimos_commit ovrimos_connect ovrimos_cursor ovrimos_exec ovrimos_execute ovrimos_fetch_into ovrimos_fetch_row ovrimos_field_len ovrimos_field_name ovrimos_field_num ovrimos_field_type ovrimos_free_result ovrimos_longreadlen ovrimos_num_fields ovrimos_num_rows ovrimos_prepare ovrimos_result_all ovrimos_result ovrimos_rollback contained -syn keyword phpFunctions pcntl_exec pcntl_fork pcntl_signal pcntl_waitpid pcntl_wexitstatus pcntl_wifexited pcntl_wifsignaled pcntl_wifstopped pcntl_wstopsig pcntl_wtermsig contained -syn keyword phpFunctions preg_grep preg_match_all preg_match preg_quote preg_replace_callback preg_replace preg_split contained +syn keyword phpFunctions pcntl_exec pcntl_fork pcntl_signal pcntl_waitpid pcntl_wexitstatus pcntl_wifexited pcntl_wifsignaled pcntl_wifstopped pcntl_wstopsig pcntl_wtermsig pcntl_alarm pcntl_async_signals pcntl_errno pcntl_get_last_error pcntl_getpriority pcntl_setpriority pcntl_signal_dispatch pcntl_signal_get_handler pcntl_sigprocmask pcntl_sigtimedwait pcntl_sigwaitinfo pcntl_strerror pcntl_unshare pcntl_wait pcntl_wifcontinued contained +syn keyword phpFunctions preg_filter preg_grep preg_last_error preg_match_all preg_match preg_quote preg_replace_callback preg_replace_callback_array preg_replace preg_split contained +syn keyword phpFunctions pdo_drivers contained syn keyword phpFunctions pdf_add_annotation pdf_add_bookmark pdf_add_launchlink pdf_add_locallink pdf_add_note pdf_add_outline pdf_add_pdflink pdf_add_thumbnail pdf_add_weblink pdf_arc pdf_arcn pdf_attach_file pdf_begin_page pdf_begin_pattern pdf_begin_template pdf_circle pdf_clip pdf_close_image pdf_close_pdi_page pdf_close_pdi pdf_close pdf_closepath_fill_stroke pdf_closepath_stroke pdf_closepath pdf_concat pdf_continue_text pdf_curveto pdf_delete pdf_end_page pdf_end_pattern pdf_end_template pdf_endpath pdf_fill_stroke pdf_fill pdf_findfont pdf_get_buffer pdf_get_font pdf_get_fontname pdf_get_fontsize pdf_get_image_height pdf_get_image_width pdf_get_majorversion pdf_get_minorversion pdf_get_parameter pdf_get_pdi_parameter pdf_get_pdi_value pdf_get_value pdf_initgraphics pdf_lineto pdf_makespotcolor pdf_moveto pdf_new pdf_open_CCITT pdf_open_file pdf_open_gif pdf_open_image_file pdf_open_image pdf_open_jpeg pdf_open_memory_image pdf_open_pdi_page pdf_open_pdi pdf_open_png pdf_open_tiff pdf_open pdf_place_image pdf_place_pdi_page pdf_rect pdf_restore pdf_rotate pdf_save pdf_scale pdf_set_border_color pdf_set_border_dash pdf_set_border_style pdf_set_char_spacing pdf_set_duration pdf_set_font pdf_set_horiz_scaling pdf_set_info_author pdf_set_info_creator pdf_set_info_keywords pdf_set_info_subject pdf_set_info_title pdf_set_info pdf_set_leading pdf_set_parameter pdf_set_text_matrix pdf_set_text_pos pdf_set_text_rendering pdf_set_text_rise pdf_set_value pdf_set_word_spacing pdf_setcolor pdf_setdash pdf_setflat pdf_setfont pdf_setgray_fill pdf_setgray_stroke pdf_setgray pdf_setlinecap pdf_setlinejoin pdf_setlinewidth pdf_setmatrix pdf_setmiterlimit pdf_setpolydash pdf_setrgbcolor_fill pdf_setrgbcolor_stroke pdf_setrgbcolor pdf_show_boxed pdf_show_xy pdf_show pdf_skew pdf_stringwidth pdf_stroke pdf_translate contained syn keyword phpFunctions pfpro_cleanup pfpro_init pfpro_process_raw pfpro_process pfpro_version contained -syn keyword phpFunctions pg_affected_rows pg_cancel_query pg_client_encoding pg_close pg_connect pg_connection_busy pg_connection_reset pg_connection_status pg_convert pg_copy_from pg_copy_to pg_dbname pg_delete pg_end_copy pg_escape_bytea pg_escape_string pg_fetch_all pg_fetch_array pg_fetch_assoc pg_fetch_object pg_fetch_result pg_fetch_row pg_field_is_null pg_field_name pg_field_num pg_field_prtlen pg_field_size pg_field_type pg_free_result pg_get_notify pg_get_pid pg_get_result pg_host pg_insert pg_last_error pg_last_notice pg_last_oid pg_lo_close pg_lo_create pg_lo_export pg_lo_import pg_lo_open pg_lo_read_all pg_lo_read pg_lo_seek pg_lo_tell pg_lo_unlink pg_lo_write pg_meta_data pg_num_fields pg_num_rows pg_options pg_pconnect pg_ping pg_port pg_put_line pg_query pg_result_error pg_result_seek pg_result_status pg_select pg_send_query pg_set_client_encoding pg_trace pg_tty pg_unescape_bytea pg_untrace pg_update contained -syn keyword phpFunctions posix_ctermid posix_get_last_error posix_getcwd posix_getegid posix_geteuid posix_getgid posix_getgrgid posix_getgrnam posix_getgroups posix_getlogin posix_getpgid posix_getpgrp posix_getpid posix_getppid posix_getpwnam posix_getpwuid posix_getrlimit posix_getsid posix_getuid posix_isatty posix_kill posix_mkfifo posix_setegid posix_seteuid posix_setgid posix_setpgid posix_setsid posix_setuid posix_strerror posix_times posix_ttyname posix_uname contained +syn keyword phpFunctions pg_affected_rows pg_cancel_query pg_client_encoding pg_close pg_connect pg_connection_busy pg_connection_reset pg_connection_status pg_convert pg_copy_from pg_copy_to pg_dbname pg_delete pg_end_copy pg_escape_bytea pg_escape_string pg_fetch_all pg_fetch_array pg_fetch_assoc pg_fetch_object pg_fetch_result pg_fetch_row pg_field_is_null pg_field_name pg_field_num pg_field_prtlen pg_field_size pg_field_type pg_free_result pg_get_notify pg_get_pid pg_get_result pg_host pg_insert pg_last_error pg_last_notice pg_last_oid pg_lo_close pg_lo_create pg_lo_export pg_lo_import pg_lo_open pg_lo_read_all pg_lo_read pg_lo_seek pg_lo_tell pg_lo_unlink pg_lo_write pg_meta_data pg_num_fields pg_num_rows pg_options pg_pconnect pg_ping pg_port pg_put_line pg_query pg_result_error pg_result_seek pg_result_status pg_select pg_send_query pg_set_client_encoding pg_trace pg_tty pg_unescape_bytea pg_untrace pg_update pg_clientencoding pg_cmdtuples pg_connect_poll pg_consume_input pg_errormessage pg_escape_identifier pg_escape_literal pg_exec pg_execute pg_fetch_all_columns pg_field_table pg_field_type_oid pg_fieldisnull pg_fieldname pg_fieldnum pg_fieldprtlen pg_fieldsize pg_fieldtype pg_flush pg_freeresult pg_getlastoid pg_lo_truncate pg_loclose pg_locreate pg_loexport pg_loimport pg_loopen pg_loread pg_loreadall pg_lounlink pg_lowrite pg_numfields pg_numrows pg_parameter_status pg_prepare pg_query_params pg_result pg_result_error_field pg_send_execute pg_send_prepare pg_send_query_params pg_set_error_verbosity pg_setclientencoding pg_socket pg_transaction_status pg_version contained +syn keyword phpFunctions posix_ctermid posix_get_last_error posix_getcwd posix_getegid posix_geteuid posix_getgid posix_getgrgid posix_getgrnam posix_getgroups posix_getlogin posix_getpgid posix_getpgrp posix_getpid posix_getppid posix_getpwnam posix_getpwuid posix_getrlimit posix_getsid posix_getuid posix_isatty posix_kill posix_mkfifo posix_setegid posix_seteuid posix_setgid posix_setpgid posix_setsid posix_setuid posix_strerror posix_times posix_ttyname posix_uname posix_access posix_errno posix_initgroups posix_mknod posix_setrlimit contained syn keyword phpFunctions printer_abort printer_close printer_create_brush printer_create_dc printer_create_font printer_create_pen printer_delete_brush printer_delete_dc printer_delete_font printer_delete_pen printer_draw_bmp printer_draw_chord printer_draw_elipse printer_draw_line printer_draw_pie printer_draw_rectangle printer_draw_roundrect printer_draw_text printer_end_doc printer_end_page printer_get_option printer_list printer_logical_fontheight printer_open printer_select_brush printer_select_font printer_select_pen printer_set_option printer_start_doc printer_start_page printer_write contained -syn keyword phpFunctions pspell_add_to_personal pspell_add_to_session pspell_check pspell_clear_session pspell_config_create pspell_config_ignore pspell_config_mode pspell_config_personal pspell_config_repl pspell_config_runtogether pspell_config_save_repl pspell_new_config pspell_new_personal pspell_new pspell_save_wordlist pspell_store_replacement pspell_suggest contained +syn keyword phpFunctions pspell_add_to_personal pspell_add_to_session pspell_check pspell_clear_session pspell_config_create pspell_config_ignore pspell_config_mode pspell_config_personal pspell_config_repl pspell_config_runtogether pspell_config_save_repl pspell_new_config pspell_new_personal pspell_new pspell_save_wordlist pspell_store_replacement pspell_suggest pspell_config_data_dir pspell_config_dict_dir contained syn keyword phpFunctions qdom_error qdom_tree contained -syn keyword phpFunctions readline_add_history readline_clear_history readline_completion_function readline_info readline_list_history readline_read_history readline_write_history readline contained +syn keyword phpFunctions readline_add_history readline_clear_history readline_completion_function readline_info readline_list_history readline_read_history readline_write_history readline readline_callback_handler_install readline_callback_handler_remove readline_callback_read_char readline_on_new_line readline_redisplay contained syn keyword phpFunctions recode_file recode_string recode contained syn keyword phpFunctions ereg_replace ereg eregi_replace eregi split spliti sql_regcase contained -syn keyword phpFunctions ftok msg_get_queue msg_receive msg_remove_queue msg_send msg_set_queue msg_stat_queue sem_acquire sem_get sem_release sem_remove shm_attach shm_detach shm_get_var shm_put_var shm_remove_var shm_remove contained +syn keyword phpFunctions ftok msg_get_queue msg_queue_exists msg_receive msg_remove_queue msg_send msg_set_queue msg_stat_queue sem_acquire sem_get sem_release sem_remove shm_attach shm_detach shm_get_var shm_has_var shm_put_var shm_remove_var shm_remove contained syn keyword phpFunctions sesam_affected_rows sesam_commit sesam_connect sesam_diagnostic sesam_disconnect sesam_errormsg sesam_execimm sesam_fetch_array sesam_fetch_result sesam_fetch_row sesam_field_array sesam_field_name sesam_free_result sesam_num_fields sesam_query sesam_rollback sesam_seek_row sesam_settransaction contained -syn keyword phpFunctions session_cache_expire session_cache_limiter session_decode session_destroy session_encode session_get_cookie_params session_id session_is_registered session_module_name session_name session_regenerate_id session_register session_save_path session_set_cookie_params session_set_save_handler session_start session_unregister session_unset session_write_close contained +syn keyword phpFunctions session_cache_expire session_cache_limiter session_decode session_destroy session_encode session_get_cookie_params session_id session_is_registered session_module_name session_name session_regenerate_id session_register session_save_path session_set_cookie_params session_set_save_handler session_start session_unregister session_unset session_write_close session_abort session_commit session_create_id session_gc session_register_shutdown session_reset session_status contained +syn keyword phpFunctions simplexml_import_dom simplexml_load_file simplexml_load_string contained syn keyword phpFunctions shmop_close shmop_delete shmop_open shmop_read shmop_size shmop_write contained syn keyword phpFunctions snmp_get_quick_print snmp_set_quick_print snmpget snmprealwalk snmpset snmpwalk snmpwalkoid contained -syn keyword phpFunctions socket_accept socket_bind socket_clear_error socket_close socket_connect socket_create_listen socket_create_pair socket_create socket_get_option socket_getpeername socket_getsockname socket_iovec_add socket_iovec_alloc socket_iovec_delete socket_iovec_fetch socket_iovec_free socket_iovec_set socket_last_error socket_listen socket_read socket_readv socket_recv socket_recvfrom socket_recvmsg socket_select socket_send socket_sendmsg socket_sendto socket_set_block socket_set_nonblock socket_set_option socket_shutdown socket_strerror socket_write socket_writev contained +syn keyword phpFunctions is_soap_fault use_soap_error_handler contained +syn keyword phpFunctions socket_accept socket_bind socket_clear_error socket_close socket_connect socket_create_listen socket_create_pair socket_create socket_get_option socket_getpeername socket_getsockname socket_iovec_add socket_iovec_alloc socket_iovec_delete socket_iovec_fetch socket_iovec_free socket_iovec_set socket_last_error socket_listen socket_read socket_readv socket_recv socket_recvfrom socket_recvmsg socket_select socket_send socket_sendmsg socket_sendto socket_set_block socket_set_nonblock socket_set_option socket_shutdown socket_strerror socket_write socket_writev socket_addrinfo_bind socket_addrinfo_connect socket_addrinfo_explain socket_addrinfo_lookup socket_cmsg_space socket_export_stream socket_getopt socket_import_stream socket_setopt contained +syn keyword phpFunctions class_implements class_parents class_uses iterator_apply iterator_count iterator_to_array spl_autoload spl_autoload_call spl_autoload_extensions spl_autoload_functions spl_autoload_register spl_autoload_unregister spl_classes spl_object_hash spl_object_id contained syn keyword phpFunctions sqlite_array_query sqlite_busy_timeout sqlite_changes sqlite_close sqlite_column sqlite_create_aggregate sqlite_create_function sqlite_current sqlite_error_string sqlite_escape_string sqlite_fetch_array sqlite_fetch_single sqlite_fetch_string sqlite_field_name sqlite_has_more sqlite_last_error sqlite_last_insert_rowid sqlite_libencoding sqlite_libversion sqlite_next sqlite_num_fields sqlite_num_rows sqlite_open sqlite_popen sqlite_query sqlite_rewind sqlite_seek sqlite_udf_decode_binary sqlite_udf_encode_binary sqlite_unbuffered_query contained syn keyword phpFunctions stream_context_create stream_context_get_options stream_context_set_option stream_context_set_params stream_copy_to_stream stream_filter_append stream_filter_prepend stream_filter_register stream_get_contents stream_get_filters stream_get_line stream_get_meta_data stream_get_transports stream_get_wrappers stream_register_wrapper stream_select stream_set_blocking stream_set_timeout stream_set_write_buffer stream_socket_accept stream_socket_client stream_socket_get_name stream_socket_recvfrom stream_socket_sendto stream_socket_server stream_wrapper_register contained syn keyword phpFunctions addcslashes addslashes bin2hex chop chr chunk_split convert_cyr_string count_chars crc32 crypt explode fprintf get_html_translation_table hebrev hebrevc html_entity_decode htmlentities htmlspecialchars implode join levenshtein localeconv ltrim md5_file md5 metaphone money_format nl_langinfo nl2br number_format ord parse_str print printf quoted_printable_decode quotemeta rtrim setlocale sha1_file sha1 similar_text soundex sprintf sscanf str_ireplace str_pad str_repeat str_replace str_rot13 str_shuffle str_split str_word_count strcasecmp strchr strcmp strcoll strcspn strip_tags stripcslashes stripos stripslashes stristr strlen strnatcasecmp strnatcmp strncasecmp strncmp strpos strrchr strrev strripos strrpos strspn strstr strtok strtolower strtoupper strtr substr_compare substr_count substr_replace substr trim ucfirst ucwords vprintf vsprintf wordwrap contained syn keyword phpFunctions swf_actiongeturl swf_actiongotoframe swf_actiongotolabel swf_actionnextframe swf_actionplay swf_actionprevframe swf_actionsettarget swf_actionstop swf_actiontogglequality swf_actionwaitforframe swf_addbuttonrecord swf_addcolor swf_closefile swf_definebitmap swf_definefont swf_defineline swf_definepoly swf_definerect swf_definetext swf_endbutton swf_enddoaction swf_endshape swf_endsymbol swf_fontsize swf_fontslant swf_fonttracking swf_getbitmapinfo swf_getfontinfo swf_getframe swf_labelframe swf_lookat swf_modifyobject swf_mulcolor swf_nextid swf_oncondition swf_openfile swf_ortho2 swf_ortho swf_perspective swf_placeobject swf_polarview swf_popmatrix swf_posround swf_pushmatrix swf_removeobject swf_rotate swf_scale swf_setfont swf_setframe swf_shapearc swf_shapecurveto3 swf_shapecurveto swf_shapefillbitmapclip swf_shapefillbitmaptile swf_shapefilloff swf_shapefillsolid swf_shapelinesolid swf_shapelineto swf_shapemoveto swf_showframe swf_startbutton swf_startdoaction swf_startshape swf_startsymbol swf_textwidth swf_translate swf_viewport contained syn keyword phpFunctions sybase_affected_rows sybase_close sybase_connect sybase_data_seek sybase_deadlock_retry_count sybase_fetch_array sybase_fetch_assoc sybase_fetch_field sybase_fetch_object sybase_fetch_row sybase_field_seek sybase_free_result sybase_get_last_message sybase_min_client_severity sybase_min_error_severity sybase_min_message_severity sybase_min_server_severity sybase_num_fields sybase_num_rows sybase_pconnect sybase_query sybase_result sybase_select_db sybase_set_message_handler sybase_unbuffered_query contained -syn keyword phpFunctions tidy_access_count tidy_clean_repair tidy_config_count tidy_diagnose tidy_error_count tidy_get_body tidy_get_config tidy_get_error_buffer tidy_get_head tidy_get_html_ver tidy_get_html tidy_get_output tidy_get_release tidy_get_root tidy_get_status tidy_getopt tidy_is_xhtml tidy_load_config tidy_parse_file tidy_parse_string tidy_repair_file tidy_repair_string tidy_reset_config tidy_save_config tidy_set_encoding tidy_setopt tidy_warning_count contained +syn keyword phpFunctions tidy_access_count tidy_clean_repair tidy_config_count tidy_diagnose tidy_error_count tidy_get_body tidy_get_config tidy_get_error_buffer tidy_get_head tidy_get_html_ver tidy_get_html tidy_get_output tidy_get_release tidy_get_root tidy_get_status tidy_getopt tidy_is_xhtml tidy_load_config tidy_parse_file tidy_parse_string tidy_repair_file tidy_repair_string tidy_reset_config tidy_save_config tidy_set_encoding tidy_setopt tidy_warning_count tidy_is_xml tidy_get_opt_doc contained syn keyword phpMethods attributes children get_attr get_nodes has_children has_siblings is_asp is_comment is_html is_jsp is_jste is_text is_xhtml is_xml next prev tidy_node contained syn keyword phpFunctions token_get_all token_name contained syn keyword phpFunctions base64_decode base64_encode get_meta_tags http_build_query parse_url rawurldecode rawurlencode urldecode urlencode contained syn keyword phpFunctions doubleval empty floatval get_defined_vars get_resource_type gettype import_request_variables intval is_array is_bool is_callable is_double is_float is_int is_integer is_long is_null is_numeric is_object is_real is_resource is_scalar is_string isset print_r serialize settype strval unserialize unset var_dump var_export contained +syn keyword phpFunctions get_called_class property_exists interface_exists trait_exists class_alias get_mangled_object_vars set_exception_handler restore_exception_handler get_declared_traits get_declared_interfaces get_resources gc_mem_caches gc_collect_cycles gc_enabled gc_enable gc_disable gc_status contained syn keyword phpFunctions vpopmail_add_alias_domain_ex vpopmail_add_alias_domain vpopmail_add_domain_ex vpopmail_add_domain vpopmail_add_user vpopmail_alias_add vpopmail_alias_del_domain vpopmail_alias_del vpopmail_alias_get_all vpopmail_alias_get vpopmail_auth_user vpopmail_del_domain_ex vpopmail_del_domain vpopmail_del_user vpopmail_error vpopmail_passwd vpopmail_set_user_quota contained syn keyword phpFunctions w32api_deftype w32api_init_dtype w32api_invoke_function w32api_register_function w32api_set_call_method contained syn keyword phpFunctions wddx_add_vars wddx_deserialize wddx_packet_end wddx_packet_start wddx_serialize_value wddx_serialize_vars contained syn keyword phpFunctions utf8_decode utf8_encode xml_error_string xml_get_current_byte_index xml_get_current_column_number xml_get_current_line_number xml_get_error_code xml_parse_into_struct xml_parse xml_parser_create_ns xml_parser_create xml_parser_free xml_parser_get_option xml_parser_set_option xml_set_character_data_handler xml_set_default_handler xml_set_element_handler xml_set_end_namespace_decl_handler xml_set_external_entity_ref_handler xml_set_notation_decl_handler xml_set_object xml_set_processing_instruction_handler xml_set_start_namespace_decl_handler xml_set_unparsed_entity_decl_handler contained -syn keyword phpFunctions xmlrpc_decode_request xmlrpc_decode xmlrpc_encode_request xmlrpc_encode xmlrpc_get_type xmlrpc_parse_method_descriptions xmlrpc_server_add_introspection_data xmlrpc_server_call_method xmlrpc_server_create xmlrpc_server_destroy xmlrpc_server_register_introspection_callback xmlrpc_server_register_method xmlrpc_set_type contained +syn keyword phpFunctions xmlrpc_decode_request xmlrpc_decode xmlrpc_encode_request xmlrpc_encode xmlrpc_get_type xmlrpc_parse_method_descriptions xmlrpc_server_add_introspection_data xmlrpc_server_call_method xmlrpc_server_create xmlrpc_server_destroy xmlrpc_server_register_introspection_callback xmlrpc_server_register_method xmlrpc_set_type xmlrpc_is_fault contained +syn keyword phpFunctions xmlwriter_end_attribute xmlwriter_end_cdata xmlwriter_end_comment xmlwriter_end_document xmlwriter_end_dtd xmlwriter_end_dtd_attlist xmlwriter_end_dtd_element xmlwriter_end_dtd_entity xmlwriter_end_element xmlwriter_end_pi xmlwriter_flush xmlwriter_full_end_element xmlwriter_open_memory xmlwriter_open_uri xmlwriter_output_memory xmlwriter_set_indent xmlwriter_set_indent_string xmlwriter_start_attribute xmlwriter_start_attribute_ns xmlwriter_start_cdata xmlwriter_start_comment xmlwriter_start_document xmlwriter_start_dtd xmlwriter_start_dtd_attlist xmlwriter_start_dtd_element xmlwriter_start_dtd_entity xmlwriter_start_element xmlwriter_start_element_ns xmlwriter_start_pi xmlwriter_text xmlwriter_write_attribute xmlwriter_write_attribute_ns xmlwriter_write_cdata xmlwriter_write_comment xmlwriter_write_dtd xmlwriter_write_dtd_attlist xmlwriter_write_dtd_element xmlwriter_write_dtd_entity xmlwriter_write_element xmlwriter_write_element_ns xmlwriter_write_pi xmlwriter_write_raw contained syn keyword phpFunctions xslt_create xslt_errno xslt_error xslt_free xslt_output_process xslt_set_base xslt_set_encoding xslt_set_error_handler xslt_set_log xslt_set_sax_handler xslt_set_sax_handlers xslt_set_scheme_handler xslt_set_scheme_handlers contained syn keyword phpFunctions yaz_addinfo yaz_ccl_conf yaz_ccl_parse yaz_close yaz_connect yaz_database yaz_element yaz_errno yaz_error yaz_es_result yaz_get_option yaz_hits yaz_itemorder yaz_present yaz_range yaz_record yaz_scan_result yaz_scan yaz_schema yaz_search yaz_set_option yaz_sort yaz_syntax yaz_wait contained syn keyword phpFunctions zip_close zip_entry_close zip_entry_compressedsize zip_entry_compressionmethod zip_entry_filesize zip_entry_name zip_entry_open zip_entry_read zip_open zip_read contained -syn keyword phpFunctions gzclose gzcompress gzdeflate gzencode gzeof gzfile gzgetc gzgets gzgetss gzinflate gzopen gzpassthru gzputs gzread gzrewind gzseek gztell gzuncompress gzwrite readgzfile zlib_get_coding_type contained +syn keyword phpFunctions gzclose gzcompress gzdeflate gzencode gzeof gzfile gzgetc gzgets gzgetss gzinflate gzopen gzpassthru gzputs gzread gzrewind gzseek gztell gzuncompress gzwrite readgzfile zlib_get_coding_type gzdecode zlib_encode zlib_decode deflate_init deflate_add inflate_init inflate_add inflate_get_status inflate_get_read_len contained if exists( "php_baselib" ) syn keyword phpMethods query next_record num_rows affected_rows nf f p np num_fields haltmsg seek link_id query_id metadata table_names nextid connect halt free register unregister is_registered delete url purl self_url pself_url hidden_session add_query padd_query reimport_get_vars reimport_post_vars reimport_cookie_vars set_container set_tokenname release_token put_headers get_id get_id put_id freeze thaw gc reimport_any_vars start url purl login_if is_authenticated auth_preauth auth_loginform auth_validatelogin auth_refreshlogin auth_registerform auth_doregister start check have_perm permsum perm_invalid contained @@ -246,12 +267,12 @@ if exists( "php_baselib" ) endif " Conditional -syn keyword phpConditional declare else enddeclare endswitch elseif endif if switch contained +syn keyword phpConditional declare else enddeclare endswitch elseif endif if switch match contained " Repeat syn keyword phpRepeat as do endfor endforeach endwhile for foreach while contained -" Repeat +" Label syn keyword phpLabel case default switch contained " Statement @@ -275,7 +296,8 @@ syn match phpOperator "&&\|\<and\>" contained display syn match phpOperator "||\|\<x\=or\>" contained display syn match phpRelation "[!=<>]=" contained display syn match phpRelation "[<>]" contained display -syn match phpMemberSelector "->" contained display +" PHP 8.0 adds the nullsafe operator ?-> for property access and method calls. +syn match phpMemberSelector "?\?->" contained display syn match phpVarSelector "\$" contained display " Identifier @@ -285,37 +307,37 @@ syn region phpIdentifierComplex matchgroup=phpParent start="{\$"rs=e-1 end="}" c syn region phpIdentifierComplexP matchgroup=phpParent start="\[" end="]" contains=@phpClInside contained " Interpolated indentifiers (inside strings) - syn match phpBrackets "[][}{]" contained display - " errors - syn match phpInterpSimpleError "\[[^]]*\]" contained display " fallback (if nothing else matches) - syn match phpInterpSimpleError "->[^a-zA-Z_]" contained display - " make sure these stay above the correct DollarCurlies so they don't take priority - syn match phpInterpBogusDollarCurley "${[^}]*}" contained display " fallback (if nothing else matches) - syn match phpinterpSimpleBracketsInner "\w\+" contained - syn match phpInterpSimpleBrackets "\[\h\w*]" contained contains=phpBrackets,phpInterpSimpleBracketsInner - syn match phpInterpSimpleBrackets "\[\d\+]" contained contains=phpBrackets,phpInterpSimpleBracketsInner - syn match phpInterpSimpleBrackets "\[0[xX]\x\+]" contained contains=phpBrackets,phpInterpSimpleBracketsInner - syn match phpInterpSimple "\$\h\w*\(\[[^]]*\]\|->\h\w*\)\?" contained contains=phpInterpSimpleBrackets,phpIdentifier,phpInterpSimpleError,phpMethods,phpMemberSelector display - syn match phpInterpVarname "\h\w*" contained - syn match phpInterpMethodName "\h\w*" contained " default color - syn match phpInterpSimpleCurly "\${\h\w*}" contains=phpInterpVarname contained extend - syn region phpInterpDollarCurley1Helper matchgroup=phpParent start="{" end="\[" contains=phpInterpVarname contained - syn region phpInterpDollarCurly1 matchgroup=phpParent start="\${\h\w*\["rs=s+1 end="]}" contains=phpInterpDollarCurley1Helper,@phpClConst contained extend - - syn match phpInterpDollarCurley2Helper "{\h\w*->" contains=phpBrackets,phpInterpVarname,phpMemberSelector contained - - syn region phpInterpDollarCurly2 matchgroup=phpParent start="\${\h\w*->"rs=s+1 end="}" contains=phpInterpDollarCurley2Helper,phpInterpMethodName contained - - syn match phpInterpBogusDollarCurley "${\h\w*->}" contained display - syn match phpInterpBogusDollarCurley "${\h\w*\[]}" contained display - - syn region phpInterpComplex matchgroup=phpParent start="{\$"rs=e-1 end="}" contains=phpIdentifier,phpMemberSelector,phpVarSelector,phpIdentifierComplexP contained extend - syn region phpIdentifierComplexP matchgroup=phpParent start="\[" end="]" contains=@phpClInside contained - " define a cluster to get all interpolation syntaxes for double-quoted strings - syn cluster phpInterpDouble contains=phpInterpSimple,phpInterpSimpleCurly,phpInterpDollarCurly1,phpInterpDollarCurly2,phpInterpBogusDollarCurley,phpInterpComplex - -" Methoden -syn match phpMethodsVar "->\h\w*" contained contains=phpMethods,phpMemberSelector display + syn match phpBrackets "[][}{]" contained display + " errors + syn match phpInterpSimpleError "\[[^]]*\]" contained display " fallback (if nothing else matches) + syn match phpInterpSimpleError "?\?->[^a-zA-Z_]" contained display + " make sure these stay above the correct DollarCurlies so they don't take priority + syn match phpInterpBogusDollarCurley "${[^}]*}" contained display " fallback (if nothing else matches) + syn match phpinterpSimpleBracketsInner "\w\+" contained + syn match phpInterpSimpleBrackets "\[\h\w*]" contained contains=phpBrackets,phpInterpSimpleBracketsInner + syn match phpInterpSimpleBrackets "\[\d\+]" contained contains=phpBrackets,phpInterpSimpleBracketsInner + syn match phpInterpSimpleBrackets "\[0[xX]\x\+]" contained contains=phpBrackets,phpInterpSimpleBracketsInner + syn match phpInterpSimple "\$\h\w*\(\[[^]]*\]\|?\?->\h\w*\)\?" contained contains=phpInterpSimpleBrackets,phpIdentifier,phpInterpSimpleError,phpMethods,phpMemberSelector display + syn match phpInterpVarname "\h\w*" contained + syn match phpInterpMethodName "\h\w*" contained " default color + syn match phpInterpSimpleCurly "\${\h\w*}" contains=phpInterpVarname contained extend + syn region phpInterpDollarCurley1Helper matchgroup=phpParent start="{" end="\[" contains=phpInterpVarname contained + syn region phpInterpDollarCurly1 matchgroup=phpParent start="\${\h\w*\["rs=s+1 end="]}" contains=phpInterpDollarCurley1Helper,@phpClConst contained extend + + syn match phpInterpDollarCurley2Helper "{\h\w*?\?->" contains=phpBrackets,phpInterpVarname,phpMemberSelector contained + + syn region phpInterpDollarCurly2 matchgroup=phpParent start="\${\h\w*?\?->"rs=s+1 end="}" contains=phpInterpDollarCurley2Helper,phpInterpMethodName contained + + syn match phpInterpBogusDollarCurley "${\h\w*?\?->}" contained display + syn match phpInterpBogusDollarCurley "${\h\w*\[]}" contained display + + syn region phpInterpComplex matchgroup=phpParent start="{\$"rs=e-1 end="}" contains=phpIdentifier,phpMemberSelector,phpVarSelector,phpIdentifierComplexP contained extend + syn region phpIdentifierComplexP matchgroup=phpParent start="\[" end="]" contains=@phpClInside contained + " define a cluster to get all interpolation syntaxes for double-quoted strings + syn cluster phpInterpDouble contains=phpInterpSimple,phpInterpSimpleCurly,phpInterpDollarCurly1,phpInterpDollarCurly2,phpInterpBogusDollarCurley,phpInterpComplex + +" Methods +syn match phpMethodsVar "?\?->\h\w*" contained contains=phpMethods,phpMemberSelector display " Include syn keyword phpInclude include require include_once require_once use contained @@ -326,24 +348,28 @@ syn keyword phpDefine new clone contained " Boolean syn keyword phpBoolean true false contained -" Number -syn match phpNumber "-\=\<\d\+\>" contained display -syn match phpNumber "\<0x\x\{1,8}\>" contained display - " Float -syn match phpFloat "\(-\=\<\d+\|-\=\)\.\d\+\>" contained display +" Refer to: https://www.php.net/manual/en/language.types.float.php +syn match phpFloat "\%(\w\|\.\)\@<!\%(\d_\?\|\.\)*\d\%(\d\|_\|\.\)*\%([eE][+-]\=\%(\d\|_\|\.\)\+\)\=\%(\w\|\.\)\@!" contained contains=phpFloatError display +syn match phpFloatError "\%([eE.][0-9._+-]*\.\|__\|_\(\>\|[eE]\)\|\(\>\|[eE]\)_\)" contained display + +" Number +syn match phpNumber "\%(\.\)\@<!\<\%([1-9]\d*\|0\|0[xX]\(\x_\?\)*\x\)\>\%(\.\)\@!" contained display +syn match phpNumber "\%(\.\)\@<!\<0\d\+\>\%(\.\)\@!" contained contains=phpOctalError display +syn match phpBinaryError "[2-9]" contained display +syn match phpNumber "\%(\.\)\@<!\<0[bB]\(\d_\?\)*\d\>\%(\.\)\@!" contained contains=phpBinaryError display " Backslash escapes - syn case match - " for double quotes and heredoc - syn match phpBackslashSequences "\\[fnrtv\\\"$]" contained display - syn match phpBackslashSequences "\\\d\{1,3}" contained contains=phpOctalError display - syn match phpBackslashSequences "\\x\x\{1,2}" contained display - " additional sequence for double quotes only - syn match phpBackslashDoubleQuote "\\[\"]" contained display - " for single quotes only - syn match phpBackslashSingleQuote "\\[\\']" contained display - syn case ignore +syn case match +" for double quotes and heredoc +syn match phpBackslashSequences "\\[fnrtv\\\"$]" contained display +syn match phpBackslashSequences "\\\d\{1,3}" contained contains=phpOctalError display +syn match phpBackslashSequences "\\x\x\{1,2}" contained display +" additional sequence for double quotes only +syn match phpBackslashDoubleQuote "\\[\"]" contained display +" for single quotes only +syn match phpBackslashSingleQuote "\\[\\']" contained display +syn case ignore " Error @@ -379,30 +405,31 @@ endif syn case match " HereDoc -syn region phpHereDoc matchgroup=Delimiter start="\(<<<\)\@<=\(\"\=\)\z(\I\i*\)\2$" end="^\z1\(;\=$\)\@=" contained contains=phpIdentifier,phpIdentifierSimply,phpIdentifierComplex,phpBackslashSequences,phpMethodsVar,@Spell keepend extend +syn region phpHereDoc matchgroup=Delimiter start="\(<<<\)\@<=\(\"\=\)\z(\I\i*\)\2$" end="^\s*\z1\>" contained contains=phpIdentifier,phpIdentifierSimply,phpIdentifierComplex,phpBackslashSequences,phpMethodsVar,@Spell keepend extend " including HTML,JavaScript,SQL even if not enabled via options -syn region phpHereDoc matchgroup=Delimiter start="\(<<<\)\@<=\(\"\=\)\z(\(\I\i*\)\=\(html\)\c\(\i*\)\)\2$" end="^\z1\(;\=$\)\@=" contained contains=@htmlTop,phpIdentifier,phpIdentifierSimply,phpIdentifierComplex,phpBackslashSequences,phpMethodsVar,@Spell keepend extend -syn region phpHereDoc matchgroup=Delimiter start="\(<<<\)\@<=\(\"\=\)\z(\(\I\i*\)\=\(sql\)\c\(\i*\)\)\2$" end="^\z1\(;\=$\)\@=" contained contains=@sqlTop,phpIdentifier,phpIdentifierSimply,phpIdentifierComplex,phpBackslashSequences,phpMethodsVar,@Spell keepend extend -syn region phpHereDoc matchgroup=Delimiter start="\(<<<\)\@<=\(\"\=\)\z(\(\I\i*\)\=\(javascript\)\c\(\i*\)\)\2$" end="^\z1\(;\=$\)\@=" contained contains=@htmlJavascript,phpIdentifierSimply,phpIdentifier,phpIdentifierComplex,phpBackslashSequences,phpMethodsVar,@Spell keepend extend +syn region phpHereDoc matchgroup=Delimiter start="\(<<<\)\@<=\(\"\=\)\z(\(\I\i*\)\=\(html\)\c\(\i*\)\)\2$" end="^\s*\z1\>" contained contains=@htmlTop,phpIdentifier,phpIdentifierSimply,phpIdentifierComplex,phpBackslashSequences,phpMethodsVar,@Spell keepend extend +syn region phpHereDoc matchgroup=Delimiter start="\(<<<\)\@<=\(\"\=\)\z(\(\I\i*\)\=\(sql\)\c\(\i*\)\)\2$" end="^\s*\z1\>" contained contains=@sqlTop,phpIdentifier,phpIdentifierSimply,phpIdentifierComplex,phpBackslashSequences,phpMethodsVar,@Spell keepend extend +syn region phpHereDoc matchgroup=Delimiter start="\(<<<\)\@<=\(\"\=\)\z(\(\I\i*\)\=\(javascript\)\c\(\i*\)\)\2$" end="^\s*\z1\>" contained contains=@htmlJavascript,phpIdentifierSimply,phpIdentifier,phpIdentifierComplex,phpBackslashSequences,phpMethodsVar,@Spell keepend extend " NowDoc -syn region phpNowDoc matchgroup=Delimiter start="\(<<<\)\@<='\z(\I\i*\)'$" end="^\z1\(;\=$\)\@=" contained contains=@Spell keepend extend +syn region phpNowDoc matchgroup=Delimiter start="\(<<<\)\@<='\z(\I\i*\)'$" end="^\s*\z1\>" contained contains=@Spell keepend extend " including HTML,JavaScript,SQL even if not enabled via options -syn region phpNowDoc matchgroup=Delimiter start="\(<<<\)\@<='\z(\(\I\i*\)\=\(html\)\c\(\i*\)\)'$" end="^\z1\(;\=$\)\@=" contained contains=@htmlTop,@Spell keepend extend -syn region phpNowDoc matchgroup=Delimiter start="\(<<<\)\@<='\z(\(\I\i*\)\=\(sql\)\c\(\i*\)\)'$" end="^\z1\(;\=$\)\@=" contained contains=@sqlTop,@Spell keepend extend -syn region phpNowDoc matchgroup=Delimiter start="\(<<<\)\@<='\z(\(\I\i*\)\=\(javascript\)\c\(\i*\)\)'$" end="^\z1\(;\=$\)\@=" contained contains=@htmlJavascript,@Spell keepend extend +syn region phpNowDoc matchgroup=Delimiter start="\(<<<\)\@<='\z(\(\I\i*\)\=\(html\)\c\(\i*\)\)'$" end="^\s*\z1\>" contained contains=@htmlTop,@Spell keepend extend +syn region phpNowDoc matchgroup=Delimiter start="\(<<<\)\@<='\z(\(\I\i*\)\=\(sql\)\c\(\i*\)\)'$" end="^\s*\z1\>" contained contains=@sqlTop,@Spell keepend extend +syn region phpNowDoc matchgroup=Delimiter start="\(<<<\)\@<='\z(\(\I\i*\)\=\(javascript\)\c\(\i*\)\)'$" end="^\s*\z1\>" contained contains=@htmlJavascript,@Spell keepend extend syn case ignore " Parent if exists("php_parent_error_close") || exists("php_parent_error_open") syn match phpParent "[{}]" contained syn region phpParent matchgroup=Delimiter start="(" end=")" contained contains=@phpClInside transparent - syn region phpParent matchgroup=Delimiter start="\[" end="\]" contained contains=@phpClInside transparent + syn region phpParent matchgroup=Delimiter start="#\?\[" end="\]" contained contains=@phpClInside transparent if !exists("php_parent_error_close") syn match phpParent "[\])]" contained endif else syn match phpParent "[({[\]})]" contained + syn match phpParent "#\[" contained endif syn cluster phpClConst contains=phpFunctions,phpIdentifier,phpConditional,phpRepeat,phpStatement,phpOperator,phpRelation,phpStringSingle,phpStringDouble,phpBacktick,phpNumber,phpFloat,phpKeyword,phpType,phpBoolean,phpStructure,phpMethodsVar,phpConstant,phpCoreConstant,phpException @@ -438,6 +465,7 @@ if exists("php_folding") && php_folding==1 " match one line constructs here and skip them at folding syn keyword phpSCKeyword abstract final private protected public static contained syn keyword phpFCKeyword function contained + syn keyword phpDefine fn contained syn keyword phpStorageClass global contained syn match phpDefine "\(\s\|^\)\(abstract\s\+\|final\s\+\|private\s\+\|protected\s\+\|public\s\+\|static\s\+\)*function\(\s\+.*[;}]\)\@=" contained contains=phpSCKeyword syn match phpStructure "\(\s\|^\)\(abstract\s\+\|final\s\+\)*\(trait\|class\)\(\s\+.*}\)\@=" contained @@ -455,7 +483,7 @@ if exists("php_folding") && php_folding==1 syn region phpFoldCatch matchgroup=Exception start="^\z(\s*\)catch\s\+\([^}]*$\)\@=" matchgroup=Delimiter end="^\z1}" contains=@phpClFunction,phpFoldFunction contained transparent fold extend syn region phpFoldTry matchgroup=Exception start="^\z(\s*\)try\s\+\([^}]*$\)\@=" matchgroup=Delimiter end="^\z1}" contains=@phpClFunction,phpFoldFunction contained transparent fold extend else - syn keyword phpDefine function contained + syn keyword phpDefine function fn contained syn keyword phpStructure abstract class trait interface contained syn keyword phpException catch throw try finally contained syn keyword phpStorageClass final global private protected public static contained @@ -489,16 +517,22 @@ hi def link phpSpecialFunction phpOperator " Highlighting for PHP5's built-in classes " - built-in classes harvested from get_declared_classes() in 5.1.4 syntax keyword phpClasses containedin=ALLBUT,phpComment,phpStringDouble,phpStringSingle,phpIdentifier,phpMethodsVar - \ stdClass __PHP_Incomplete_Class php_user_filter Directory ArrayObject + \ stdClass __PHP_Incomplete_Class php_user_filter AssertionError Directory ArrayObject \ Exception ErrorException LogicException BadFunctionCallException BadMethodCallException DomainException + \ ArgumentCountError ArithmeticError ClosedGeneratorException Closure CompileError DivisionByZeroError Generator ParseError TypeError WeakReference \ RecursiveIteratorIterator IteratorIterator FilterIterator RecursiveFilterIterator ParentIterator LimitIterator \ CachingIterator RecursiveCachingIterator NoRewindIterator AppendIterator InfiniteIterator EmptyIterator \ ArrayIterator RecursiveArrayIterator DirectoryIterator RecursiveDirectoryIterator + \ CallbackFilterIterator FilesystemIterator GlobIterator MultipleIterator RecursiveCallbackFilterIterator + \ RecursiveRegexIterator RecursiveTreeIterator RegexIterator SplDoublyLinkedList + \ SplFixedArray SplHeap SplMaxHeap SplMinHeap SplPriorityQueue SplQueue SplStack \ InvalidArgumentException LengthException OutOfRangeException RuntimeException OutOfBoundsException \ OverflowException RangeException UnderflowException UnexpectedValueException \ PDO PDOException PDOStatement PDORow \ Reflection ReflectionFunction ReflectionParameter ReflectionMethod ReflectionClass \ ReflectionObject ReflectionProperty ReflectionExtension ReflectionException + \ ReflectionClassConstant ReflectionFunctionAbstract ReflectionGenerator ReflectionNamedType + \ ReflectionReference ReflectionType ReflectionZendExtension \ SplFileInfo SplFileObject SplTempFileObject SplObjectStorage \ XMLWriter LibXMLError XMLReader SimpleXMLElement SimpleXMLIterator \ DOMException DOMStringList DOMNameList DOMDomError DOMErrorHandler @@ -507,13 +541,33 @@ syntax keyword phpClasses containedin=ALLBUT,phpComment,phpStringDouble,phpStrin \ DOMCharacterData DOMAttr DOMElement DOMText DOMComment DOMTypeinfo DOMUserDataHandler \ DOMLocator DOMConfiguration DOMCdataSection DOMDocumentType DOMNotation DOMEntity \ DOMEntityReference DOMProcessingInstruction DOMStringExtend DOMXPath + \ APCIterator APCuIterator + \ CURLFile + \ DateInterval DatePeriod DateTime DateTimeImmutable DateTimeZone + \ finfo + \ GMP + \ Collator IntlBreakIterator IntlCalendar IntlChar IntlCodePointBreakIterator IntlDateFormatter IntlException IntlGregorianCalendar IntlIterator IntlPartsIterator IntlRuleBasedBreakIterator IntlTimeZone Locale MessageFormatter Normalizer NumberFormatter ResourceBundle Spoofchecker Transliterator UConverter + \ FFI CData CType ParserException + \ HashContext + \ JsonException + \ Memcached MemcachedException + \ mysqli mysqli_driver mysqli_result mysqli_sql_exception mysqli_stmt mysqli_warning + \ SessionHandler + \ SoapClient SoapFault SoapHeader SoapParam SoapServer SoapVar + \ SQLite3 SQLite3Result SQLite3Stmt + \ tidy tidyNode + \ XSLTProcessor ZipArchive + \ Phar PharData PharException PharFileInfo + hi def link phpClasses phpFunctions -" Highlighting for PHP5's built-in interfaces -" - built-in classes harvested from get_declared_interfaces() in 5.1.4 +" Highlighting for PHP's built-in interfaces syntax keyword phpInterfaces containedin=ALLBUT,phpComment,phpStringDouble,phpStringSingle,phpIdentifier,phpMethodsVar \ Iterator IteratorAggregate RecursiveIterator OuterIterator SeekableIterator \ Traversable ArrayAccess Serializable Countable SplObserver SplSubject Reflector + \ Throwable DateTimeInterface JsonSerializable SessionHandlerInterface SessionIdInterface SessionUpdateTimestampHandlerInterface + \ + hi def link phpInterfaces phpConstant " option defaults: @@ -535,6 +589,7 @@ if php_special_functions " - eval() is the token 'make_your_code_twice_as_complex()' function for PHP. " - user_error()/trigger_error() can be overloaded by set_error_handler and also " have the capacity to terminate your script when type is E_USER_ERROR. + " - match(){} is not a function syntax keyword phpSpecialFunction containedin=ALLBUT,phpComment,phpStringDouble,phpStringSingle \ user_error trigger_error isset unset eval extract compact empty endif @@ -623,6 +678,8 @@ hi def link phpBrackets Delimiter hi def link phpIdentifierConst Delimiter hi def link phpParentError Error hi def link phpOctalError Error +hi def link phpBinaryError Error +hi def link phpFloatError Error hi def link phpInterpSimpleError Error hi def link phpInterpBogusDollarCurley Error hi def link phpInterpDollarCurly1 Error diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim index 6f0818c845..1a37af1c8a 100644 --- a/runtime/syntax/vim.vim +++ b/runtime/syntax/vim.vim @@ -398,7 +398,7 @@ syn match vimMenuBang "!" contained skipwhite nextgroup=@vimMenuList " Angle-Bracket Notation (tnx to Michael Geddes) {{{2 " ====================== syn case ignore -syn match vimNotation "\%#=1\(\\\|<lt>\)\=<\([scamd]-\)\{0,4}x\=\(f\d\{1,2}\|[^ \t:]\|cmd\|cr\|lf\|linefeed\|return\|k\=del\%[ete]\|bs\|backspace\|tab\|esc\|right\|left\|help\|undo\|insert\|ins\|mouse\|k\=home\|k\=end\|kplus\|kminus\|kdivide\|kmultiply\|kenter\|kpoint\|space\|k\=\(page\)\=\(\|down\|up\|k\d\>\)\)>" contains=vimBracket +syn match vimNotation "\%#=1\(\\\|<lt>\)\=<\([scamd]-\)\{0,4}x\=\(f\d\{1,2}\|[^ \t:]\|cmd\|cr\|lf\|linefeed\|return\|enter\|k\=del\%[ete]\|bs\|backspace\|tab\|esc\|right\|left\|help\|undo\|insert\|ins\|mouse\|k\=home\|k\=end\|kplus\|kminus\|kdivide\|kmultiply\|kenter\|kpoint\|space\|k\=\(page\)\=\(\|down\|up\|k\d\>\)\)>" contains=vimBracket syn match vimNotation "\%#=1\(\\\|<lt>\)\=<\([scam2-4]-\)\{0,4}\(right\|left\|middle\)\(mouse\)\=\(drag\|release\)\=>" contains=vimBracket syn match vimNotation "\%#=1\(\\\|<lt>\)\=<\(bslash\|plug\|sid\|space\|bar\|nop\|nul\|lt\)>" contains=vimBracket syn match vimNotation '\(\\\|<lt>\)\=<C-R>[0-9a-z"%#:.\-=]'he=e-1 contains=vimBracket diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py index b1a7f92854..0507e4b7b6 100755 --- a/scripts/gen_vimdoc.py +++ b/scripts/gen_vimdoc.py @@ -186,6 +186,7 @@ param_exclude = ( # Annotations are displayed as line items after API function descriptions. annotation_map = { 'FUNC_API_FAST': '{fast}', + 'FUNC_API_CHECK_TEXTLOCK': 'not allowed when |textlock| is active', } diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index db37e2100d..f1151d196a 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -121,6 +121,8 @@ Integer nvim_buf_line_count(Buffer buffer, Error *err) /// - buffer handle /// - utf_sizes: include UTF-32 and UTF-16 size of the replaced /// region, as args to `on_lines`. +/// - preview: also attach to command preview (i.e. 'inccommand') +/// events. /// @param[out] err Error details, if any /// @return False if attach failed (invalid parameter, or buffer isn't loaded); /// otherwise True. TODO: LUA_API_NO_EVAL @@ -176,6 +178,12 @@ Boolean nvim_buf_attach(uint64_t channel_id, goto error; } cb.utf_sizes = v->data.boolean; + } else if (is_lua && strequal("preview", k.data)) { + if (v->type != kObjectTypeBoolean) { + api_set_error(err, kErrorTypeValidation, "preview must be boolean"); + goto error; + } + cb.preview = v->data.boolean; } else { api_set_error(err, kErrorTypeValidation, "unexpected key: %s", k.data); goto error; @@ -329,6 +337,7 @@ void nvim_buf_set_lines(uint64_t channel_id, ArrayOf(String) replacement, Error *err) FUNC_API_SINCE(1) + FUNC_API_CHECK_TEXTLOCK { buf_T *buf = find_buffer_by_handle(buffer, err); @@ -779,6 +788,7 @@ Boolean nvim_buf_is_loaded(Buffer buffer) /// - unload: Unloaded only, do not delete. See |:bunload| void nvim_buf_delete(Buffer buffer, Dictionary opts, Error *err) FUNC_API_SINCE(7) + FUNC_API_CHECK_TEXTLOCK { buf_T *buf = find_buffer_by_handle(buffer, err); diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 8b80d4aad9..1e972e01be 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -857,6 +857,7 @@ String nvim_get_current_line(Error *err) /// @param[out] err Error details, if any void nvim_set_current_line(String line, Error *err) FUNC_API_SINCE(1) + FUNC_API_CHECK_TEXTLOCK { buffer_set_line(curbuf->handle, curwin->w_cursor.lnum - 1, line, err); } @@ -866,6 +867,7 @@ void nvim_set_current_line(String line, Error *err) /// @param[out] err Error details, if any void nvim_del_current_line(Error *err) FUNC_API_SINCE(1) + FUNC_API_CHECK_TEXTLOCK { buffer_del_line(curbuf->handle, curwin->w_cursor.lnum - 1, err); } @@ -1060,6 +1062,7 @@ Buffer nvim_get_current_buf(void) /// @param[out] err Error details, if any void nvim_set_current_buf(Buffer buffer, Error *err) FUNC_API_SINCE(1) + FUNC_API_CHECK_TEXTLOCK { buf_T *buf = find_buffer_by_handle(buffer, err); @@ -1114,6 +1117,7 @@ Window nvim_get_current_win(void) /// @param[out] err Error details, if any void nvim_set_current_win(Window window, Error *err) FUNC_API_SINCE(1) + FUNC_API_CHECK_TEXTLOCK { win_T *win = find_window_by_handle(window, err); @@ -1263,6 +1267,7 @@ fail: Window nvim_open_win(Buffer buffer, Boolean enter, Dictionary config, Error *err) FUNC_API_SINCE(6) + FUNC_API_CHECK_TEXTLOCK { FloatConfig fconfig = FLOAT_CONFIG_INIT; if (!parse_float_config(config, &fconfig, false, err)) { @@ -1327,6 +1332,7 @@ Tabpage nvim_get_current_tabpage(void) /// @param[out] err Error details, if any void nvim_set_current_tabpage(Tabpage tabpage, Error *err) FUNC_API_SINCE(1) + FUNC_API_CHECK_TEXTLOCK { tabpage_T *tp = find_tab_by_handle(tabpage, err); @@ -1411,6 +1417,7 @@ Dictionary nvim_get_namespaces(void) /// - false: Client must cancel the paste. Boolean nvim_paste(String data, Boolean crlf, Integer phase, Error *err) FUNC_API_SINCE(6) + FUNC_API_CHECK_TEXTLOCK { static bool draining = false; bool cancel = false; @@ -1483,6 +1490,7 @@ theend: void nvim_put(ArrayOf(String) lines, String type, Boolean after, Boolean follow, Error *err) FUNC_API_SINCE(6) + FUNC_API_CHECK_TEXTLOCK { yankreg_T *reg = xcalloc(sizeof(yankreg_T), 1); if (!prepare_yankreg_from_object(reg, type, lines.size)) { diff --git a/src/nvim/api/window.c b/src/nvim/api/window.c index a3ec1c8e53..f4af1632ec 100644 --- a/src/nvim/api/window.c +++ b/src/nvim/api/window.c @@ -44,6 +44,7 @@ Buffer nvim_win_get_buf(Window window, Error *err) /// @param[out] err Error details, if any void nvim_win_set_buf(Window window, Buffer buffer, Error *err) FUNC_API_SINCE(5) + FUNC_API_CHECK_TEXTLOCK { win_T *win = find_window_by_handle(window, err), *save_curwin = curwin; buf_T *buf = find_buffer_by_handle(buffer, err); @@ -500,6 +501,7 @@ Dictionary nvim_win_get_config(Window window, Error *err) /// @param[out] err Error details, if any void nvim_win_close(Window window, Boolean force, Error *err) FUNC_API_SINCE(6) + FUNC_API_CHECK_TEXTLOCK { win_T *win = find_window_by_handle(window, err); if (!win) { diff --git a/src/nvim/arabic.c b/src/nvim/arabic.c index 7f12c0c798..9fba38a49f 100644 --- a/src/nvim/arabic.c +++ b/src/nvim/arabic.c @@ -719,9 +719,7 @@ int arabic_shape(int c, int *ccp, int *c1p, int prev_c, int prev_c1, // half-shape current and previous character int shape_c = half_shape(prev_c); - // Save away current character - int curr_c = c; - + int curr_c; int curr_laa = A_firstc_laa(c, *c1p); int prev_laa = A_firstc_laa(prev_c, prev_c1); diff --git a/src/nvim/ascii.h b/src/nvim/ascii.h index 2397af27cc..f41068ea70 100644 --- a/src/nvim/ascii.h +++ b/src/nvim/ascii.h @@ -89,6 +89,10 @@ static inline bool ascii_iswhite(int) REAL_FATTR_CONST REAL_FATTR_ALWAYS_INLINE; +static inline bool ascii_iswhite_or_nul(int) + REAL_FATTR_CONST + REAL_FATTR_ALWAYS_INLINE; + static inline bool ascii_isdigit(int) REAL_FATTR_CONST REAL_FATTR_ALWAYS_INLINE; @@ -117,6 +121,14 @@ static inline bool ascii_iswhite(int c) return c == ' ' || c == '\t'; } +/// Checks if `c` is a space or tab character or NUL. +/// +/// @see {ascii_isdigit} +static inline bool ascii_iswhite_or_nul(int c) +{ + return ascii_iswhite(c) || c == NUL; +} + /// Check whether character is a decimal digit. /// /// Library isdigit() function is officially locale-dependent and, for diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index 53b11c250e..42224d0a4f 100644 --- a/src/nvim/autocmd.c +++ b/src/nvim/autocmd.c @@ -1106,9 +1106,9 @@ void aucmd_prepbuf(aco_save_T *aco, buf_T *buf) win = curwin; } - aco->save_curwin = curwin; - aco->save_prevwin = prevwin; + aco->save_curwin_handle = curwin->handle; aco->save_curbuf = curbuf; + aco->save_prevwin_handle = prevwin == NULL ? 0 : prevwin->handle; if (win != NULL) { // There is a window for "buf" in the current tab page, make it the // curwin. This is preferred, it has the least side effects (esp. if @@ -1148,7 +1148,7 @@ void aucmd_prepbuf(aco_save_T *aco, buf_T *buf) curwin = aucmd_win; } curbuf = buf; - aco->new_curwin = curwin; + aco->new_curwin_handle = curwin->handle; set_bufref(&aco->new_curbuf, curbuf); } @@ -1194,14 +1194,14 @@ void aucmd_restbuf(aco_save_T *aco) unblock_autocmds(); - if (win_valid(aco->save_curwin)) { - curwin = aco->save_curwin; + win_T *const save_curwin = win_find_by_handle(aco->save_curwin_handle); + if (save_curwin != NULL) { + curwin = save_curwin; } else { // Hmm, original window disappeared. Just use the first one. curwin = firstwin; } - prevwin = win_valid(aco->save_prevwin) ? aco->save_prevwin - : firstwin; // window disappeared? + prevwin = win_find_by_handle(aco->save_prevwin_handle); vars_clear(&aucmd_win->w_vars->dv_hashtab); // free all w: variables hash_init(&aucmd_win->w_vars->dv_hashtab); // re-use the hashtab curbuf = curwin->w_buffer; @@ -1216,11 +1216,14 @@ void aucmd_restbuf(aco_save_T *aco) curwin->w_topfill = 0; } } else { - // restore curwin - if (win_valid(aco->save_curwin)) { + // Restore curwin. Use the window ID, a window may have been closed + // and the memory re-used for another one. + win_T *const save_curwin = win_find_by_handle(aco->save_curwin_handle); + if (save_curwin != NULL) { // Restore the buffer which was previously edited by curwin, if it was // changed, we are still the same window and the buffer is valid. - if (curwin == aco->new_curwin && curbuf != aco->new_curbuf.br_buf + if (curwin->handle == aco->new_curwin_handle + && curbuf != aco->new_curbuf.br_buf && bufref_valid(&aco->new_curbuf) && aco->new_curbuf.br_buf->b_ml.ml_mfp != NULL) { if (curwin->w_s == &curbuf->b_s) { @@ -1232,10 +1235,9 @@ void aucmd_restbuf(aco_save_T *aco) curbuf->b_nwindows++; } - curwin = aco->save_curwin; - prevwin = win_valid(aco->save_prevwin) ? aco->save_prevwin - : firstwin; // window disappeared? + curwin = save_curwin; curbuf = curwin->w_buffer; + prevwin = win_find_by_handle(aco->save_prevwin_handle); // In case the autocommand moves the cursor to a position that does not // exist in curbuf check_cursor(); @@ -1717,7 +1719,8 @@ void unblock_autocmds(void) } } -static inline bool is_autocmd_blocked(void) +bool is_autocmd_blocked(void) + FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT { return autocmd_blocked != 0; } diff --git a/src/nvim/autocmd.h b/src/nvim/autocmd.h index af1eeb0fc4..1c0f88f08f 100644 --- a/src/nvim/autocmd.h +++ b/src/nvim/autocmd.h @@ -7,13 +7,13 @@ // Struct to save values in before executing autocommands for a buffer that is // not the current buffer. typedef struct { - buf_T *save_curbuf; ///< saved curbuf - int use_aucmd_win; ///< using aucmd_win - win_T *save_curwin; ///< saved curwin - win_T *save_prevwin; ///< saved prevwin - win_T *new_curwin; ///< new curwin - bufref_T new_curbuf; ///< new curbuf - char_u *globaldir; ///< saved value of globaldir + buf_T *save_curbuf; ///< saved curbuf + bool use_aucmd_win; ///< using aucmd_win + handle_T save_curwin_handle; ///< ID of saved curwin + handle_T new_curwin_handle; ///< ID of new curwin + handle_T save_prevwin_handle; ///< ID of saved prevwin + bufref_T new_curbuf; ///< new curbuf + char_u *globaldir; ///< saved value of globaldir } aco_save_T; typedef struct AutoCmd { diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 839d61cd2e..93a03986e5 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -602,8 +602,12 @@ void close_buffer(win_T *win, buf_T *buf, int action, bool abort_if_last) * Remove the buffer from the list. */ if (wipe_buf) { - xfree(buf->b_ffname); - xfree(buf->b_sfname); + if (buf->b_sfname != buf->b_ffname) { + XFREE_CLEAR(buf->b_sfname); + } else { + buf->b_sfname = NULL; + } + XFREE_CLEAR(buf->b_ffname); if (buf->b_prev == NULL) { firstbuf = buf->b_next; } else { @@ -1583,7 +1587,7 @@ void enter_buffer(buf_T *buf) need_fileinfo = true; // display file info after redraw } // check if file changed - (void)buf_check_timestamp(curbuf, false); + (void)buf_check_timestamp(curbuf); curwin->w_topline = 1; curwin->w_topfill = 0; @@ -1693,15 +1697,18 @@ static inline void buf_init_changedtick(buf_T *const buf) /// if the buffer already exists. /// This is the ONLY way to create a new buffer. /// -/// @param ffname full path of fname or relative -/// @param sfname short fname or NULL +/// @param ffname_arg full path of fname or relative +/// @param sfname_arg short fname or NULL /// @param lnum preferred cursor line /// @param flags BLN_ defines /// @param bufnr /// /// @return pointer to the buffer -buf_T * buflist_new(char_u *ffname, char_u *sfname, linenr_T lnum, int flags) +buf_T *buflist_new(char_u *ffname_arg, char_u *sfname_arg, linenr_T lnum, + int flags) { + char_u *ffname = ffname_arg; + char_u *sfname = sfname_arg; buf_T *buf; fname_expand(curbuf, &ffname, &sfname); // will allocate ffname @@ -1787,8 +1794,12 @@ buf_T * buflist_new(char_u *ffname, char_u *sfname, linenr_T lnum, int flags) 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); - XFREE_CLEAR(buf->b_sfname); if (buf != curbuf) { free_buffer(buf); } @@ -2778,28 +2789,32 @@ int buflist_name_nr(int fnum, char_u **fname, linenr_T *lnum) return OK; } -/* - * Set the file name for "buf"' to 'ffname', short file name to 'sfname'. - * The file name with the full path is also remembered, for when :cd is used. - * Returns FAIL for failure (file name already in use by other buffer) - * OK otherwise. - */ -int -setfname( +// Set the file name for "buf" to "ffname_arg", short file name to +// "sfname_arg". +// The file name with the full path is also remembered, for when :cd is used. +// Returns FAIL for failure (file name already in use by other buffer) +// OK otherwise. +int setfname( buf_T *buf, - char_u *ffname, - char_u *sfname, + char_u *ffname_arg, + char_u *sfname_arg, bool message // give message when buffer already exists ) { + char_u *ffname = ffname_arg; + char_u *sfname = sfname_arg; buf_T *obuf = NULL; FileID file_id; bool file_id_valid = false; if (ffname == NULL || *ffname == NUL) { // Removing the name. + if (buf->b_sfname != buf->b_ffname) { + XFREE_CLEAR(buf->b_sfname); + } else { + buf->b_sfname = NULL; + } XFREE_CLEAR(buf->b_ffname); - XFREE_CLEAR(buf->b_sfname); } else { fname_expand(buf, &ffname, &sfname); // will allocate ffname if (ffname == NULL) { // out of memory @@ -2830,8 +2845,10 @@ setfname( #ifdef USE_FNAME_CASE path_fix_case(sfname); // set correct case for short file name #endif + if (buf->b_sfname != buf->b_ffname) { + xfree(buf->b_sfname); + } xfree(buf->b_ffname); - xfree(buf->b_sfname); buf->b_ffname = ffname; buf->b_sfname = sfname; } @@ -2857,7 +2874,9 @@ void buf_set_name(int fnum, char_u *name) buf = buflist_findnr(fnum); if (buf != NULL) { - xfree(buf->b_sfname); + if (buf->b_sfname != buf->b_ffname) { + xfree(buf->b_sfname); + } xfree(buf->b_ffname); buf->b_ffname = vim_strsave(name); buf->b_sfname = NULL; @@ -4633,16 +4652,18 @@ static bool append_arg_number(win_T *wp, char_u *buf, int buflen, bool add_file) return true; } -/* - * Make "ffname" a full file name, set "sfname" to "ffname" if not NULL. - * "ffname" becomes a pointer to allocated memory (or NULL). - */ +// Make "*ffname" a full file name, set "*sfname" to "*ffname" if not NULL. +// "*ffname" becomes a pointer to allocated memory (or NULL). +// When resolving a link both "*sfname" and "*ffname" will point to the same +// allocated memory. +// The "*ffname" and "*sfname" pointer values on call will not be freed. +// Note that the resulting "*ffname" pointer should be considered not allocaed. void fname_expand(buf_T *buf, char_u **ffname, char_u **sfname) { - if (*ffname == NULL) { // if no file name given, nothing to do + if (*ffname == NULL) { // no file name given, nothing to do return; } - if (*sfname == NULL) { // if no short file name given, use ffname + if (*sfname == NULL) { // no short file name given, use ffname *sfname = *ffname; } *ffname = (char_u *)fix_fname((char *)(*ffname)); // expand to full path @@ -4685,7 +4706,6 @@ do_arg_all( int keep_tabs // keep current tabs, for ":tab drop file" ) { - int i; char_u *opened; // Array of weight for which args are open: // 0: not opened // 1: opened in other tab @@ -4694,6 +4714,7 @@ do_arg_all( int opened_len; // length of opened[] int use_firstwin = false; // use first window for arglist + bool tab_drop_empty_window = false; int split_ret = OK; bool p_ea_save; alist_T *alist; // argument list to be used @@ -4741,6 +4762,7 @@ do_arg_all( win_T *wpnext = NULL; tpnext = curtab->tp_next; for (win_T *wp = firstwin; wp != NULL; wp = wpnext) { + int i; wpnext = wp->w_next; buf = wp->w_buffer; if (buf->b_ffname == NULL @@ -4846,14 +4868,15 @@ do_arg_all( last_curwin = curwin; last_curtab = curtab; win_enter(lastwin, false); - // ":drop all" should re-use an empty window to avoid "--remote-tab" + // ":tab drop file" should re-use an empty window to avoid "--remote-tab" // leaving an empty tab page when executed locally. if (keep_tabs && BUFEMPTY() && curbuf->b_nwindows == 1 && curbuf->b_ffname == NULL && !curbuf->b_changed) { use_firstwin = true; + tab_drop_empty_window = true; } - for (i = 0; i < count && i < opened_len && !got_int; i++) { + for (int i = 0; i < count && !got_int; i++) { if (alist == &global_alist && i == global_alist.al_ga.ga_len - 1) { arg_had_last = true; } @@ -4873,6 +4896,10 @@ do_arg_all( } } } else if (split_ret == OK) { + // trigger events for tab drop + if (tab_drop_empty_window && i == count - 1) { + autocmd_no_enter--; + } if (!use_firstwin) { // split current window p_ea_save = p_ea; p_ea = true; // use space from all windows @@ -4898,6 +4925,9 @@ do_arg_all( || bufIsChanged(curwin->w_buffer)) ? ECMD_HIDE : 0) + ECMD_OLDBUF, curwin); + if (tab_drop_empty_window && i == count - 1) { + autocmd_no_enter++; + } if (use_firstwin) { autocmd_no_leave++; } @@ -5449,7 +5479,9 @@ int buf_signcols(buf_T *buf) curline = sign->lnum; linesum = 0; } - linesum++; + if (sign->has_text_or_icon) { + linesum++; + } } if (linesum > buf->b_signcols_max) { buf->b_signcols_max = linesum; diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index dba02a67e8..cc09b7e989 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -491,9 +491,10 @@ typedef struct { LuaRef on_changedtick; LuaRef on_detach; bool utf_sizes; + bool preview; } BufUpdateCallbacks; #define BUF_UPDATE_CALLBACKS_INIT { LUA_NOREF, LUA_NOREF, LUA_NOREF, \ - LUA_NOREF, false } + LUA_NOREF, false, false } EXTERN int curbuf_splice_pending INIT(= 0); @@ -532,9 +533,11 @@ struct file_buffer { // b_fname is the same as b_sfname, unless ":cd" has been done, // then it is the same as b_ffname (NULL for no name). // - char_u *b_ffname; // full path file name - char_u *b_sfname; // short file name - char_u *b_fname; // current file name + char_u *b_ffname; // full path file name, allocated + char_u *b_sfname; // short file name, allocated, may be equal to + // b_ffname + char_u *b_fname; // current file name, points to b_ffname or + // b_sfname bool file_id_valid; FileID file_id; diff --git a/src/nvim/buffer_updates.c b/src/nvim/buffer_updates.c index fc671ad9e2..68e123896b 100644 --- a/src/nvim/buffer_updates.c +++ b/src/nvim/buffer_updates.c @@ -237,7 +237,7 @@ void buf_updates_send_changes(buf_T *buf, for (size_t i = 0; i < kv_size(buf->update_callbacks); i++) { BufUpdateCallbacks cb = kv_A(buf->update_callbacks, i); bool keep = true; - if (cb.on_lines != LUA_NOREF) { + if (cb.on_lines != LUA_NOREF && (cb.preview || !(State & CMDPREVIEW))) { Array args = ARRAY_DICT_INIT; Object items[8]; args.size = 6; // may be increased to 8 below @@ -298,7 +298,7 @@ void buf_updates_send_splice( for (size_t i = 0; i < kv_size(buf->update_callbacks); i++) { BufUpdateCallbacks cb = kv_A(buf->update_callbacks, i); bool keep = true; - if (cb.on_bytes != LUA_NOREF) { + if (cb.on_bytes != LUA_NOREF && (cb.preview || !(State & CMDPREVIEW))) { FIXED_TEMP_ARRAY(args, 11); // the first argument is always the buffer handle diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 1cdf84f9d0..93bc34fa4b 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -805,7 +805,7 @@ static void diff_try_update(diffio_T *dio, for (idx_new = idx_orig; idx_new < DB_COUNT; idx_new++) { buf = curtab->tp_diffbuf[idx_new]; if (buf_valid(buf)) { - buf_check_timestamp(buf, false); + buf_check_timestamp(buf); } } } @@ -1225,8 +1225,7 @@ void ex_diffpatch(exarg_T *eap) EMSG(_("E816: Cannot read patch output")); } else { if (curbuf->b_fname != NULL) { - newname = vim_strnsave(curbuf->b_fname, - (int)(STRLEN(curbuf->b_fname) + 4)); + newname = vim_strnsave(curbuf->b_fname, STRLEN(curbuf->b_fname) + 4); STRCAT(newname, ".new"); } diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 1cf821f786..962ef9b245 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -381,7 +381,7 @@ static void insert_enter(InsertState *s) // Need to recompute the cursor position, it might move when the cursor is // on a TAB or special character. - curs_columns(true); + curs_columns(curwin, true); // Enable langmap or IME, indicated by 'iminsert'. // Note that IME may enabled/disabled without us noticing here, thus the @@ -594,7 +594,7 @@ static int insert_check(VimState *state) if (curwin->w_wcol < s->mincol - curbuf->b_p_ts && curwin->w_wrow == curwin->w_winrow - + curwin->w_height_inner - 1 - get_scrolloff_value() + + curwin->w_height_inner - 1 - get_scrolloff_value(curwin) && (curwin->w_cursor.lnum != curwin->w_topline || curwin->w_topfill > 0)) { if (curwin->w_topfill > 0) { @@ -608,7 +608,7 @@ static int insert_check(VimState *state) } // May need to adjust w_topline to show the cursor. - update_topline(); + update_topline(curwin); s->did_backspace = false; @@ -1561,7 +1561,7 @@ void edit_putchar(int c, bool highlight) int attr; if (curwin->w_grid.chars != NULL || default_grid.chars != NULL) { - update_topline(); // just in case w_topline isn't valid + update_topline(curwin); // just in case w_topline isn't valid validate_cursor(); if (highlight) { attr = HL_ATTR(HLF_8); @@ -1677,7 +1677,7 @@ void display_dollar(colnr_T col) // If on the last byte of a multi-byte move to the first byte. char_u *p = get_cursor_line_ptr(); curwin->w_cursor.col -= utf_head_off(p, p + col); - curs_columns(false); // Recompute w_wrow and w_wcol + curs_columns(curwin, false); // Recompute w_wrow and w_wcol if (curwin->w_wcol < curwin->w_grid.Columns) { edit_putchar('$', false); dollar_vcol = curwin->w_virtcol; @@ -3423,7 +3423,7 @@ static void ins_compl_addleader(int c) xfree(compl_leader); compl_leader = vim_strnsave(get_cursor_line_ptr() + compl_col, - (int)(curwin->w_cursor.col - compl_col)); + curwin->w_cursor.col - compl_col); ins_compl_new_leader(); } @@ -3716,7 +3716,7 @@ static bool ins_compl_prep(int c) retval = true; } - auto_format(FALSE, TRUE); + auto_format(false, true); // Trigger the CompleteDonePre event to give scripts a chance to // act upon the completion before clearing the info, and restore @@ -3810,10 +3810,10 @@ static void ins_compl_fixRedoBufForLeader(char_u *ptr_arg) */ static buf_T *ins_compl_next_buf(buf_T *buf, int flag) { - static win_T *wp; + static win_T *wp = NULL; if (flag == 'w') { // just windows - if (buf == curbuf) { // first call for this flag/expansion + if (buf == curbuf || wp == NULL) { // first call for this flag/expansion wp = curwin; } assert(wp); @@ -5327,8 +5327,9 @@ static int ins_complete(int c, bool enable_pum) compl_curr_match->cp_number); edit_submode_extra = match_ref; edit_submode_highl = HLF_R; - if (dollar_vcol >= 0) - curs_columns(FALSE); + if (dollar_vcol >= 0) { + curs_columns(curwin, false); + } } } } @@ -6158,7 +6159,7 @@ internal_format ( curwin->w_p_lbr = has_lbr; if (!format_only && haveto_redraw) { - update_topline(); + update_topline(curwin); redraw_curbuf_later(VALID); } } @@ -6503,7 +6504,7 @@ stop_insert ( curwin->w_cursor = tpos; } - auto_format(TRUE, FALSE); + auto_format(true, false); if (ascii_iswhite(cc)) { if (gchar_cursor() != NUL) @@ -6807,7 +6808,7 @@ cursor_up ( coladvance(curwin->w_curswant); if (upd_topline) { - update_topline(); // make sure curwin->w_topline is valid + update_topline(curwin); // make sure curwin->w_topline is valid } return OK; @@ -6858,7 +6859,7 @@ cursor_down ( coladvance(curwin->w_curswant); if (upd_topline) { - update_topline(); // make sure curwin->w_topline is valid + update_topline(curwin); // make sure curwin->w_topline is valid } return OK; @@ -7802,7 +7803,7 @@ static bool ins_esc(long *count, int cmdchar, bool nomove) // Otherwise remove the mode message. if (reg_recording != 0 || restart_edit != NUL) { showmode(); - } else if (p_smd) { + } else if (p_smd && (got_int || !skip_showmode())) { MSG(""); } // Exit Insert mode diff --git a/src/nvim/eval.c b/src/nvim/eval.c index a7a860ba72..7916e3a66a 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -2556,6 +2556,7 @@ void free_for_info(void *fi_void) void set_context_for_expression(expand_T *xp, char_u *arg, cmdidx_T cmdidx) + FUNC_ATTR_NONNULL_ALL { int got_eq = FALSE; int c; @@ -2638,6 +2639,23 @@ void set_context_for_expression(expand_T *xp, char_u *arg, cmdidx_T cmdidx) } } } + + // ":exe one two" completes "two" + if ((cmdidx == CMD_execute + || cmdidx == CMD_echo + || cmdidx == CMD_echon + || cmdidx == CMD_echomsg) + && xp->xp_context == EXPAND_EXPRESSION) { + for (;;) { + char_u *const n = skiptowhite(arg); + + if (n == arg || ascii_iswhite_or_nul(*skipwhite(n))) { + break; + } + arg = skipwhite(n); + } + } + xp->xp_pattern = arg; } @@ -5404,7 +5422,7 @@ static int get_literal_key(char_u **arg, typval_T *tv) for (p = *arg; ASCII_ISALNUM(*p) || *p == '_' || *p == '-'; p++) { } tv->v_type = VAR_STRING; - tv->vval.v_string = vim_strnsave(*arg, (int)(p - *arg)); + tv->vval.v_string = vim_strnsave(*arg, p - *arg); *arg = skipwhite(p); return OK; @@ -7070,7 +7088,7 @@ void set_buffer_lines(buf_T *buf, linenr_T lnum_arg, bool append, } } check_cursor_col(); - update_topline(); + update_topline(curwin); } if (!is_curbuf) { @@ -7782,13 +7800,13 @@ pos_T *var2fpos(const typval_T *const tv, const int dollar_lnum, if (name[0] == 'w' && dollar_lnum) { pos.col = 0; if (name[1] == '0') { // "w0": first visible line - update_topline(); + update_topline(curwin); // In silent Ex mode topline is zero, but that's not a valid line // number; use one instead. pos.lnum = curwin->w_topline > 0 ? curwin->w_topline : 1; return &pos; } else if (name[1] == '$') { // "w$": last visible line - validate_botline(); + validate_botline(curwin); // In silent Ex mode botline is zero, return zero then. pos.lnum = curwin->w_botline > 0 ? curwin->w_botline - 1 : 0; return &pos; @@ -10246,9 +10264,6 @@ repeat: if (src[*usedlen] == ':' && (src[*usedlen + 1] == 's' || (src[*usedlen + 1] == 'g' && src[*usedlen + 2] == 's'))) { - char_u *str; - char_u *pat; - char_u *sub; int sep; char_u *flags; int didit = FALSE; @@ -10265,13 +10280,13 @@ repeat: // find end of pattern p = vim_strchr(s, sep); if (p != NULL) { - pat = vim_strnsave(s, (int)(p - s)); + char_u *const pat = vim_strnsave(s, p - s); s = p + 1; // find end of substitution p = vim_strchr(s, sep); if (p != NULL) { - sub = vim_strnsave(s, (int)(p - s)); - str = vim_strnsave(*fnamep, *fnamelen); + char_u *const sub = vim_strnsave(s, p - s); + char_u *const str = vim_strnsave(*fnamep, *fnamelen); *usedlen = (size_t)(p + 1 - src); s = do_string_sub(str, pat, sub, NULL, flags); *fnamep = s; diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 89d9a85775..16eb6f8898 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -4206,6 +4206,8 @@ static void f_has(typval_T *argvars, typval_T *rettv, FunPtr fptr) n = true; } else if (STRICMP(name, "syntax_items") == 0) { n = syntax_present(curwin); + } else if (STRICMP(name, "clipboard_working") == 0) { + n = eval_has_provider("clipboard"); #ifdef UNIX } else if (STRICMP(name, "unnamedplus") == 0) { n = eval_has_provider("clipboard"); @@ -6551,7 +6553,7 @@ static void f_readfile(typval_T *argvars, typval_T *rettv, FunPtr fptr) } if (prevlen == 0) { assert(len < INT_MAX); - s = vim_strnsave(start, (int)len); + s = vim_strnsave(start, len); } else { /* Change "prev" buffer to be the right size. This way * the bytes are only copied once, and very long lines are @@ -10853,7 +10855,7 @@ static void f_trim(typval_T *argvars, typval_T *rettv, FunPtr fptr) } } } - rettv->vval.v_string = vim_strnsave(head, (int)(tail - head)); + rettv->vval.v_string = vim_strnsave(head, tail - head); } /* diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index 8daef00985..70c998ef39 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -2297,9 +2297,9 @@ void ex_function(exarg_T *eap) // Ignore leading white space. p = skipwhite(p + 4); heredoc_trimmed = - vim_strnsave(theline, (int)(skipwhite(theline) - theline)); + vim_strnsave(theline, skipwhite(theline) - theline); } - skip_until = vim_strnsave(p, (int)(skiptowhite(p) - p)); + skip_until = vim_strnsave(p, skiptowhite(p) - p); do_concat = false; is_heredoc = true; } @@ -2484,6 +2484,7 @@ errret_2: ga_clear_strings(&newlines); ret_free: xfree(skip_until); + xfree(heredoc_trimmed); xfree(line_to_free); xfree(fudi.fd_newkey); xfree(name); diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index b0a51eaefd..a7d97c904b 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -2066,19 +2066,20 @@ static int check_readonly(int *forceit, buf_T *buf) return FALSE; } -/* - * Try to abandon current file and edit a new or existing file. - * "fnum" is the number of the file, if zero use ffname/sfname. - * "lnum" is the line number for the cursor in the new file (if non-zero). - * - * Return: - * GETFILE_ERROR for "normal" error, - * GETFILE_NOT_WRITTEN for "not written" error, - * GETFILE_SAME_FILE for success - * GETFILE_OPEN_OTHER for successfully opening another file. - */ -int getfile(int fnum, char_u *ffname, char_u *sfname, int setpm, linenr_T lnum, int forceit) +// Try to abandon the current file and edit a new or existing file. +// "fnum" is the number of the file, if zero use "ffname_arg"/"sfname_arg". +// "lnum" is the line number for the cursor in the new file (if non-zero). +// +// Return: +// GETFILE_ERROR for "normal" error, +// GETFILE_NOT_WRITTEN for "not written" error, +// GETFILE_SAME_FILE for success +// GETFILE_OPEN_OTHER for successfully opening another file. +int getfile(int fnum, char_u *ffname_arg, char_u *sfname_arg, int setpm, + linenr_T lnum, int forceit) { + char_u *ffname = ffname_arg; + char_u *sfname = sfname_arg; int other; int retval; char_u *free_me = NULL; @@ -2322,7 +2323,7 @@ int do_ecmd( // Existing memfile. oldbuf = true; set_bufref(&bufref, buf); - (void)buf_check_timestamp(buf, false); + (void)buf_check_timestamp(buf); // Check if autocommands made buffer invalid or changed the current // buffer. if (!bufref_valid(&bufref) || curbuf != old_curbuf.br_buf) { @@ -2705,7 +2706,7 @@ int do_ecmd( if (topline == 0 && command == NULL) { *so_ptr = 999; // force cursor to be vertically centered in the window } - update_topline(); + update_topline(curwin); curwin->w_scbind_pos = curwin->w_topline; *so_ptr = n; redraw_curbuf_later(NOT_VALID); // redraw this buffer later @@ -2795,9 +2796,10 @@ void ex_append(exarg_T *eap) p = vim_strchr(eap->nextcmd, NL); if (p == NULL) p = eap->nextcmd + STRLEN(eap->nextcmd); - theline = vim_strnsave(eap->nextcmd, (int)(p - eap->nextcmd)); - if (*p != NUL) - ++p; + theline = vim_strnsave(eap->nextcmd, p - eap->nextcmd); + if (*p != NUL) { + p++; + } eap->nextcmd = p; } else { // Set State to avoid the cursor shape to be set to INSERT mode @@ -3704,15 +3706,16 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, + len_change; highlight_match = TRUE; - update_topline(); + update_topline(curwin); validate_cursor(); update_screen(SOME_VALID); highlight_match = false; redraw_later(curwin, SOME_VALID); curwin->w_p_fen = save_p_fen; - if (msg_row == Rows - 1) - msg_didout = FALSE; /* avoid a scroll-up */ + if (msg_row == Rows - 1) { + msg_didout = false; // avoid a scroll-up + } msg_starthere(); i = msg_scroll; msg_scroll = 0; /* truncate msg when @@ -3731,8 +3734,8 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, typed = plain_vgetc(); no_mapping--; - /* clear the question */ - msg_didout = FALSE; /* don't scroll up */ + // clear the question + msg_didout = false; // don't scroll up msg_col = 0; gotocmdline(TRUE); @@ -3909,17 +3912,13 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, ADJUST_SUB_FIRSTLNUM(); - // TODO(bfredl): adjust also in preview, because decorations? - // this has some robustness issues, will look into later. - bool do_splice = !preview; + // TODO(bfredl): this has some robustness issues, look into later. bcount_t replaced_bytes = 0; lpos_T start = regmatch.startpos[0], end = regmatch.endpos[0]; - if (do_splice) { - for (i = 0; i < nmatch-1; i++) { - replaced_bytes += STRLEN(ml_get(lnum_start+i)) + 1; - } - replaced_bytes += end.col - start.col; + for (i = 0; i < nmatch-1; i++) { + replaced_bytes += STRLEN(ml_get(lnum_start+i)) + 1; } + replaced_bytes += end.col - start.col; // Now the trick is to replace CTRL-M chars with a real line @@ -3964,14 +3963,12 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, current_match.end.col = new_endcol; current_match.end.lnum = lnum; - if (do_splice) { - int matchcols = end.col - ((end.lnum == start.lnum) - ? start.col : 0); - int subcols = new_endcol - ((lnum == lnum_start) ? start_col : 0); - extmark_splice(curbuf, lnum_start-1, start_col, - end.lnum-start.lnum, matchcols, replaced_bytes, - lnum-lnum_start, subcols, sublen-1, kExtmarkUndo); - } + int matchcols = end.col - ((end.lnum == start.lnum) + ? start.col : 0); + int subcols = new_endcol - ((lnum == lnum_start) ? start_col : 0); + extmark_splice(curbuf, lnum_start-1, start_col, + end.lnum-start.lnum, matchcols, replaced_bytes, + lnum-lnum_start, subcols, sublen-1, kExtmarkUndo); } @@ -5254,8 +5251,10 @@ void ex_viusage(exarg_T *eap) /// @param tagname Name of the tags file ("tags" for English, "tags-fr" for /// French) /// @param add_help_tags Whether to add the "help-tags" tag -static void helptags_one(char_u *const dir, const char_u *const ext, - const char_u *const tagfname, const bool add_help_tags) +/// @param ignore_writeerr ignore write error +static void helptags_one(char_u *dir, const char_u *ext, const char_u *tagfname, + bool add_help_tags, bool ignore_writeerr) + FUNC_ATTR_NONNULL_ALL { garray_T ga; int filecount; @@ -5299,7 +5298,9 @@ static void helptags_one(char_u *const dir, const char_u *const ext, FILE *const fd_tags = os_fopen((char *)NameBuff, "w"); if (fd_tags == NULL) { - EMSG2(_("E152: Cannot open %s for writing"), NameBuff); + if (!ignore_writeerr) { + EMSG2(_("E152: Cannot open %s for writing"), NameBuff); + } FreeWild(filecount, files); return; } @@ -5447,7 +5448,9 @@ static void helptags_one(char_u *const dir, const char_u *const ext, } /// Generate tags in one help directory, taking care of translations. -static void do_helptags(char_u *dirname, bool add_help_tags) +static void do_helptags(char_u *dirname, bool add_help_tags, + bool ignore_writeerr) + FUNC_ATTR_NONNULL_ALL { int len; garray_T ga; @@ -5529,17 +5532,17 @@ static void do_helptags(char_u *dirname, bool add_help_tags) ext[1] = fname[5]; ext[2] = fname[6]; } - helptags_one(dirname, ext, fname, add_help_tags); + helptags_one(dirname, ext, fname, add_help_tags, ignore_writeerr); } ga_clear(&ga); FreeWild(filecount, files); } - static void -helptags_cb(char_u *fname, void *cookie) +static void helptags_cb(char_u *fname, void *cookie) + FUNC_ATTR_NONNULL_ALL { - do_helptags(fname, *(bool *)cookie); + do_helptags(fname, *(bool *)cookie, true); } /* @@ -5568,7 +5571,7 @@ void ex_helptags(exarg_T *eap) if (dirname == NULL || !os_isdir(dirname)) { EMSG2(_("E150: Not a directory: %s"), eap->arg); } else { - do_helptags(dirname, add_help_tags); + do_helptags(dirname, add_help_tags, false); } xfree(dirname); } @@ -5739,7 +5742,7 @@ static buf_T *show_sub(exarg_T *eap, pos_T old_cusr, redraw_later(curwin, SOME_VALID); win_enter(save_curwin, false); // Return to original window - update_topline(); + update_topline(curwin); // Update screen now. int save_rd = RedrawingDisabled; diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 3b9c44c3cd..bde584d27e 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -3392,7 +3392,7 @@ void ex_checktime(exarg_T *eap) } else { buf = buflist_findnr((int)eap->line2); if (buf != NULL) { // cannot happen? - (void)buf_check_timestamp(buf, false); + (void)buf_check_timestamp(buf); } } no_check_timestamps = save_no_check_timestamps; @@ -3790,6 +3790,14 @@ void ex_drop(exarg_T *eap) if (wp->w_buffer == buf) { goto_tabpage_win(tp, wp); curwin->w_arg_idx = 0; + if (!bufIsChanged(curbuf)) { + const int save_ar = curbuf->b_p_ar; + + // reload the file if it is newer + curbuf->b_p_ar = 1; + buf_check_timestamp(curbuf); + curbuf->b_p_ar = save_ar; + } return; } } diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index a5eccc12b9..3fc02e0693 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -2979,6 +2979,15 @@ const char * set_one_cmd_context( const char *arg = (const char *)skipwhite((const char_u *)p); + // Skip over ++argopt argument + if ((ea.argt & ARGOPT) && *arg != NUL && strncmp(arg, "++", 2) == 0) { + p = arg; + while (*p && !ascii_isspace(*p)) { + MB_PTR_ADV(p); + } + arg = (const char *)skipwhite((const char_u *)p); + } + if (ea.cmdidx == CMD_write || ea.cmdidx == CMD_update) { if (*arg == '>') { // Append. if (*++arg == '>') { @@ -4979,7 +4988,6 @@ static int uc_add_command(char_u *name, size_t name_len, char_u *rep, FUNC_ATTR_NONNULL_ARG(1, 3) { ucmd_T *cmd = NULL; - char_u *p; int i; int cmp = 1; char_u *rep_buf = NULL; @@ -5039,7 +5047,7 @@ static int uc_add_command(char_u *name, size_t name_len, char_u *rep, if (cmp != 0) { ga_grow(gap, 1); - p = vim_strnsave(name, (int)name_len); + char_u *const p = vim_strnsave(name, name_len); cmd = USER_CMD_GA(gap, i); memmove(cmd + 1, cmd, (gap->ga_len - i) * sizeof(ucmd_T)); @@ -6188,8 +6196,9 @@ int parse_compl_arg(const char_u *value, int vallen, int *complp, return FAIL; } - if (arg != NULL) - *compl_arg = vim_strnsave(arg, (int)arglen); + if (arg != NULL) { + *compl_arg = vim_strnsave(arg, arglen); + } return OK; } @@ -7362,7 +7371,7 @@ static void ex_syncbind(exarg_T *eap) topline = curwin->w_topline; FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { if (wp->w_p_scb && wp->w_buffer) { - y = wp->w_buffer->b_ml.ml_line_count - get_scrolloff_value(); + y = wp->w_buffer->b_ml.ml_line_count - get_scrolloff_value(curwin); if (topline > y) { topline = y; } @@ -8050,7 +8059,7 @@ static void ex_redraw(exarg_T *eap) RedrawingDisabled = 0; p_lz = FALSE; validate_cursor(); - update_topline(); + update_topline(curwin); if (eap->forceit) { redraw_all_later(NOT_VALID); } @@ -8062,8 +8071,8 @@ static void ex_redraw(exarg_T *eap) RedrawingDisabled = r; p_lz = p; - /* Reset msg_didout, so that a message that's there is overwritten. */ - msg_didout = FALSE; + // Reset msg_didout, so that a message that's there is overwritten. + msg_didout = false; msg_col = 0; /* No need to wait after an intentional redraw. */ @@ -8199,10 +8208,11 @@ static void ex_mark(exarg_T *eap) */ void update_topline_cursor(void) { - check_cursor(); /* put cursor on valid line */ - update_topline(); - if (!curwin->w_p_wrap) + check_cursor(); // put cursor on valid line + update_topline(curwin); + if (!curwin->w_p_wrap) { validate_cursor(); + } update_curswant(); } @@ -9282,7 +9292,7 @@ static void ex_match(exarg_T *eap) } else { p = skiptowhite(eap->arg); if (!eap->skip) { - g = vim_strnsave(eap->arg, (int)(p - eap->arg)); + g = vim_strnsave(eap->arg, p - eap->arg); } p = skipwhite(p); if (*p == NUL) { diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index 0c7562980a..0917c6dd02 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -518,10 +518,13 @@ fail: * Discard an exception. "was_finished" is set when the exception has been * caught and the catch clause has been ended normally. */ -static void discard_exception(except_T *excp, int was_finished) +static void discard_exception(except_T *excp, bool was_finished) { char_u *saved_IObuff; + if (current_exception == excp) { + current_exception = NULL; + } if (excp == NULL) { internal_error("discard_exception()"); return; @@ -569,7 +572,6 @@ void discard_current_exception(void) { if (current_exception != NULL) { discard_exception(current_exception, false); - current_exception = NULL; } // Note: all globals manipulated here should be saved/restored in // try_enter/try_leave. @@ -652,8 +654,8 @@ static void finish_exception(except_T *excp) set_vim_var_string(VV_THROWPOINT, NULL, -1); } - /* Discard the exception, but use the finish message for 'verbose'. */ - discard_exception(excp, TRUE); + // Discard the exception, but use the finish message for 'verbose'. + discard_exception(excp, true); } /* @@ -1812,11 +1814,12 @@ void leave_cleanup(cleanup_T *csp) * made pending by it. Report this to the user if required by the * 'verbose' option or when debugging. */ if (aborting() || need_rethrow) { - if (pending & CSTP_THROW) - /* Cancel the pending exception (includes report). */ - discard_exception(csp->exception, FALSE); - else + if (pending & CSTP_THROW) { + // Cancel the pending exception (includes report). + discard_exception(csp->exception, false); + } else { report_discard_pending(pending, NULL); + } /* If an error was about to be converted to an exception when * enter_cleanup() was called, free the message list. */ @@ -1916,15 +1919,13 @@ 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) { - /* Cancel the pending exception. This is in the - * finally clause, so that the stack of the - * caught exceptions is not involved. */ - discard_exception((except_T *) - cstack->cs_exception[idx], - FALSE); - } else - report_discard_pending(cstack->cs_pending[idx], - NULL); + // Cancel the pending exception. This is in the + // finally clause, so that the stack of the + // caught exceptions is not involved. + discard_exception((except_T *)cstack->cs_exception[idx], false); + } else { + report_discard_pending(cstack->cs_pending[idx], NULL); + } cstack->cs_pending[idx] = CSTP_NONE; } break; diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index a0910f1394..0bc52f1e97 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -523,7 +523,7 @@ static void may_do_incsearch_highlighting(int firstc, long count, // positioned in the same way as the actual search command restore_viewstate(&s->old_viewstate); changed_cline_bef_curs(); - update_topline(); + update_topline(curwin); if (found != 0) { pos_T save_pos = curwin->w_cursor; @@ -1082,6 +1082,7 @@ static int command_line_execute(VimState *state, int key) if (s->c == K_DOWN && ccline.cmdpos > 0 && ccline.cmdbuff[ccline.cmdpos - 1] == '.') { s->c = (int)p_wc; + KeyTyped = true; // in case the key was mapped } else if (s->c == K_UP) { // Hitting <Up>: Remove one submenu name in front of the // cursor @@ -1112,6 +1113,7 @@ static int command_line_execute(VimState *state, int key) cmdline_del(i); } s->c = (int)p_wc; + KeyTyped = true; // in case the key was mapped s->xpc.xp_context = EXPAND_NOTHING; } } @@ -1134,6 +1136,7 @@ static int command_line_execute(VimState *state, int key) || ccline.cmdbuff[ccline.cmdpos - 3] != '.')) { // go down a directory s->c = (int)p_wc; + KeyTyped = true; // in case the key was mapped } else if (STRNCMP(s->xpc.xp_pattern, upseg + 1, 3) == 0 && s->c == K_DOWN) { // If in a direct ancestor, strip off one ../ to go down @@ -1154,6 +1157,7 @@ static int command_line_execute(VimState *state, int key) && (vim_ispathsep(ccline.cmdbuff[j - 3]) || j == i + 2)) { cmdline_del(j - 2); s->c = (int)p_wc; + KeyTyped = true; // in case the key was mapped } } else if (s->c == K_UP) { // go up a directory @@ -1546,7 +1550,7 @@ static int may_do_command_line_next_incsearch(int firstc, long count, set_search_match(&s->match_end); curwin->w_cursor = s->match_start; changed_cline_bef_curs(); - update_topline(); + update_topline(curwin); validate_cursor(); highlight_match = true; save_viewstate(&s->old_viewstate); @@ -2242,7 +2246,7 @@ static int command_line_changed(CommandLineState *s) // Restore the window "view". curwin->w_cursor = s->is_state.save_cursor; restore_viewstate(&s->is_state.old_viewstate); - update_topline(); + update_topline(curwin); redrawcmdline(); @@ -2251,7 +2255,9 @@ static int command_line_changed(CommandLineState *s) close_preview_windows(); update_screen(SOME_VALID); // Clear 'inccommand' preview. } else { - may_do_incsearch_highlighting(s->firstc, s->count, &s->is_state); + if (s->xpc.xp_context == EXPAND_NOTHING) { + may_do_incsearch_highlighting(s->firstc, s->count, &s->is_state); + } } if (cmdmsg_rl || (p_arshape && !p_tbidi)) { @@ -2740,8 +2746,8 @@ redraw: no_mapping--; - /* make following messages go to the next line */ - msg_didout = FALSE; + // make following messages go to the next line + msg_didout = false; msg_col = 0; if (msg_row < Rows - 1) { msg_row++; @@ -4229,17 +4235,11 @@ ExpandOne ( * Prepare an expand structure for use. */ void ExpandInit(expand_T *xp) + FUNC_ATTR_NONNULL_ALL { - xp->xp_pattern = NULL; - xp->xp_pattern_len = 0; + CLEAR_POINTER(xp); xp->xp_backslash = XP_BS_NONE; -#ifndef BACKSLASH_IN_FILENAME - xp->xp_shell = FALSE; -#endif xp->xp_numfiles = -1; - xp->xp_files = NULL; - xp->xp_arg = NULL; - xp->xp_line = NULL; } /* @@ -5399,7 +5399,7 @@ static void expand_shellcmd(char_u *filepat, int *num_file, char_u ***file, } /// Call "user_expand_func()" to invoke a user defined Vim script function and -/// return the result (either a string or a List). +/// return the result (either a string, a List or NULL). static void * call_user_expand_func(user_expand_func_T user_expand_func, expand_T *xp, int *num_file, char_u ***file) FUNC_ATTR_NONNULL_ALL diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index 42a9ef08f9..d831ffc050 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -893,6 +893,9 @@ void ex_mkrc(exarg_T *eap) && (*flagp & SSOP_OPTIONS))) { failed |= (makemap(fd, NULL) == FAIL || makeset(fd, OPT_GLOBAL, false) == FAIL); + if (p_hls && fprintf(fd, "%s", "set hlsearch\n") < 0) { + failed = true; + } } if (!failed && view_session) { @@ -949,11 +952,16 @@ void ex_mkrc(exarg_T *eap) } if (fprintf(fd, "%s", - "let &g:so = s:so_save | let &g:siso = s:siso_save\n" - "doautoall SessionLoadPost\n") + "let &g:so = s:so_save | let &g:siso = s:siso_save\n") < 0) { failed = true; } + if (no_hlsearch && fprintf(fd, "%s", "nohlsearch\n") < 0) { + failed = true; + } + if (fprintf(fd, "%s", "doautoall SessionLoadPost\n") < 0) { + failed = true; + } if (eap->cmdidx == CMD_mksession) { if (fprintf(fd, "unlet SessionLoad\n") < 0) { failed = true; diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index f4dd90fad2..a542bb19dd 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -1652,9 +1652,6 @@ failed: # ifdef HAVE_ICONV if (iconv_fd != (iconv_t)-1) { iconv_close(iconv_fd); -# ifndef __clang_analyzer__ - iconv_fd = (iconv_t)-1; -# endif } # endif @@ -2032,7 +2029,7 @@ static char_u *next_fenc(char_u **pp, bool *alloced) r = enc_canonize(*pp); *pp += STRLEN(*pp); } else { - r = vim_strnsave(*pp, (int)(p - *pp)); + r = vim_strnsave(*pp, p - *pp); *pp = p + 1; p = enc_canonize(r); xfree(r); @@ -4217,7 +4214,9 @@ void shorten_buf_fname(buf_T *buf, char_u *dirname, int force) && (force || buf->b_sfname == NULL || path_is_absolute(buf->b_sfname))) { - XFREE_CLEAR(buf->b_sfname); + if (buf->b_sfname != buf->b_ffname) { + XFREE_CLEAR(buf->b_sfname); + } p = path_shorten_fname(buf->b_ffname, dirname); if (p != NULL) { buf->b_sfname = vim_strsave(p); @@ -4673,7 +4672,6 @@ check_timestamps( ) { int didit = 0; - int n; /* Don't check timestamps while system() or another low-level function may * cause us to lose and gain focus. */ @@ -4701,7 +4699,7 @@ check_timestamps( if (buf->b_nwindows > 0) { bufref_T bufref; set_bufref(&bufref, buf); - n = buf_check_timestamp(buf, focus); + const int n = buf_check_timestamp(buf); if (didit < n) { didit = n; } @@ -4771,11 +4769,7 @@ static int move_lines(buf_T *frombuf, buf_T *tobuf) * return 2 if a message has been displayed. * return 0 otherwise. */ -int -buf_check_timestamp( - buf_T *buf, - int focus /* called for GUI focus event */ -) +int buf_check_timestamp(buf_T *buf) FUNC_ATTR_NONNULL_ALL { int retval = 0; @@ -5103,8 +5097,8 @@ void buf_reload(buf_T *buf, int orig_mode) curwin->w_topline = old_topline; curwin->w_cursor = old_cursor; check_cursor(); - update_topline(); - keep_filetype = FALSE; + update_topline(curwin); + keep_filetype = false; /* Update folds unless they are defined manually. */ FOR_ALL_TAB_WINDOWS(tp, wp) { diff --git a/src/nvim/fold.c b/src/nvim/fold.c index 654aa6d5ba..0593c16999 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -902,8 +902,9 @@ int foldMoveTo( bool last = false; for (;; ) { if (!foldFind(gap, curwin->w_cursor.lnum - lnum_off, &fp)) { - if (!updown) + if (!updown || gap->ga_len == 0) { break; + } /* When moving up, consider a fold above the cursor; when * moving down consider a fold below the cursor. */ diff --git a/src/nvim/func_attr.h b/src/nvim/func_attr.h index 38b51b5564..e0b0610646 100644 --- a/src/nvim/func_attr.h +++ b/src/nvim/func_attr.h @@ -213,6 +213,8 @@ # define FUNC_API_REMOTE_ONLY /// API function not exposed in VimL/remote. # define FUNC_API_LUA_ONLY +/// API function checked textlock. +# define FUNC_API_CHECK_TEXTLOCK /// API function introduced at the given API level. # define FUNC_API_SINCE(X) /// API function deprecated since the given API level. diff --git a/src/nvim/generators/c_grammar.lua b/src/nvim/generators/c_grammar.lua index de098b7a7b..c9ab0cf709 100644 --- a/src/nvim/generators/c_grammar.lua +++ b/src/nvim/generators/c_grammar.lua @@ -43,6 +43,7 @@ local c_proto = Ct( (fill * Cg((P('FUNC_API_NOEXPORT') * Cc(true)), 'noexport') ^ -1) * (fill * Cg((P('FUNC_API_REMOTE_ONLY') * Cc(true)), 'remote_only') ^ -1) * (fill * Cg((P('FUNC_API_LUA_ONLY') * Cc(true)), 'lua_only') ^ -1) * + (fill * Cg((P('FUNC_API_CHECK_TEXTLOCK') * Cc(true)), 'check_textlock') ^ -1) * (fill * Cg((P('FUNC_API_REMOTE_IMPL') * Cc(true)), 'remote_impl') ^ -1) * (fill * Cg((P('FUNC_API_BRIDGE_IMPL') * Cc(true)), 'bridge_impl') ^ -1) * (fill * Cg((P('FUNC_API_COMPOSITOR_IMPL') * Cc(true)), 'compositor_impl') ^ -1) * diff --git a/src/nvim/generators/gen_api_dispatch.lua b/src/nvim/generators/gen_api_dispatch.lua index b31209e8ff..7e78b9e9d6 100644 --- a/src/nvim/generators/gen_api_dispatch.lua +++ b/src/nvim/generators/gen_api_dispatch.lua @@ -260,6 +260,13 @@ for i = 1, #functions do args[#args + 1] = converted end + if fn.check_textlock then + output:write('\n if (textlock != 0) {') + output:write('\n api_set_error(error, kErrorTypeException, "%s", e_secure);') + output:write('\n goto cleanup;') + output:write('\n }\n') + end + -- function call local call_args = table.concat(args, ', ') output:write('\n ') @@ -393,6 +400,16 @@ local function process_function(fn) } ]], fn.name)) end + + if fn.check_textlock then + write_shifted_output(output, [[ + if (textlock != 0) { + api_set_error(&err, kErrorTypeException, "%s", e_secure); + goto exit_0; + } + ]]) + end + local cparams = '' local free_code = {} for j = #fn.parameters,1,-1 do diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 2e2993ed26..eddbdef739 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -2490,8 +2490,10 @@ int inchar( } // Always flush the output characters when getting input characters - // from the user. - ui_flush(); + // from the user and not just peeking. + if (wait_time == -1L || wait_time > 10L) { + ui_flush(); + } // Fill up to a third of the buffer, because each character may be // tripled below. diff --git a/src/nvim/globals.h b/src/nvim/globals.h index c53c1546a4..6b962dc1f6 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -139,8 +139,9 @@ EXTERN int mod_mask INIT(= 0x0); // current key modifiers EXTERN int cmdline_row; EXTERN int redraw_cmdline INIT(= false); // cmdline must be redrawn +EXTERN bool redraw_mode INIT(= false); // mode must be redrawn EXTERN int clear_cmdline INIT(= false); // cmdline must be cleared -EXTERN int mode_displayed INIT(= false); // mode is being displayed +EXTERN bool mode_displayed INIT(= false); // mode is being displayed EXTERN int cmdline_star INIT(= false); // cmdline is crypted EXTERN int redrawing_cmdline INIT(= false); // cmdline is being redrawn EXTERN int cmdline_was_last_drawn INIT(= false); // cmdline was last drawn @@ -199,7 +200,7 @@ EXTERN int keep_msg_attr INIT(= 0); // highlight attr for keep_msg EXTERN int keep_msg_more INIT(= false); // keep_msg was set by msgmore() EXTERN int need_fileinfo INIT(= false); // do fileinfo() after redraw EXTERN int msg_scroll INIT(= false); // msg_start() will scroll -EXTERN int msg_didout INIT(= false); // msg_outstr() was used in line +EXTERN bool msg_didout INIT(= false); // msg_outstr() was used in line EXTERN int msg_didany INIT(= false); // msg_outstr() was used at all EXTERN int msg_nowait INIT(= false); // don't wait for this msg EXTERN int emsg_off INIT(= 0); // don't display errors for now, diff --git a/src/nvim/main.c b/src/nvim/main.c index fd8264583b..e068b2361c 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -539,7 +539,7 @@ int main(int argc, char **argv) // When a startup script or session file setup for diff'ing and // scrollbind, sync the scrollbind now. if (curwin->w_p_diff && curwin->w_p_scb) { - update_topline(); + update_topline(curwin); check_scrollbind((linenr_T)0, 0L); TIME_MSG("diff scrollbinding"); } @@ -653,7 +653,18 @@ void getout(int exitval) } } } - apply_autocmds(EVENT_VIMLEAVEPRE, NULL, NULL, FALSE, curbuf); + + int unblock = 0; + // deathtrap() blocks autocommands, but we do want to trigger + // VimLeavePre. + if (is_autocmd_blocked()) { + unblock_autocmds(); + unblock++; + } + apply_autocmds(EVENT_VIMLEAVEPRE, NULL, NULL, false, curbuf); + if (unblock) { + block_autocmds(); + } } if (p_shada && *p_shada != NUL) { @@ -662,7 +673,17 @@ void getout(int exitval) } if (v_dying <= 1) { + int unblock = 0; + + // deathtrap() blocks autocommands, but we do want to trigger VimLeave. + if (is_autocmd_blocked()) { + unblock_autocmds(); + unblock++; + } apply_autocmds(EVENT_VIMLEAVE, NULL, NULL, false, curbuf); + if (unblock) { + block_autocmds(); + } } profile_dump(); @@ -1985,7 +2006,7 @@ static void version(void) info_message = TRUE; // use mch_msg(), not mch_errmsg() list_version(); msg_putchar('\n'); - msg_didout = FALSE; + msg_didout = false; } /// Prints help message for "nvim -h" or "nvim --help". diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 70225484ec..31dc6b3649 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -975,9 +975,9 @@ void ml_recover(bool checkext) if (b0p->b0_flags & B0_HAS_FENC) { int fnsize = B0_FNAME_SIZE_NOCRYPT; - for (p = b0p->b0_fname + fnsize; p > b0p->b0_fname && p[-1] != NUL; --p) - ; - b0_fenc = vim_strnsave(p, (int)(b0p->b0_fname + fnsize - p)); + for (p = b0p->b0_fname + fnsize; p > b0p->b0_fname && p[-1] != NUL; p--) { + } + b0_fenc = vim_strnsave(p, b0p->b0_fname + fnsize - p); } mf_put(mfp, hp, false, false); /* release block 0 */ diff --git a/src/nvim/message.c b/src/nvim/message.c index 02a7732f5c..530b930fed 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1128,11 +1128,11 @@ void wait_return(int redraw) if (p_more) { if (c == 'b' || c == 'k' || c == 'u' || c == 'g' || c == K_UP || c == K_PAGEUP) { - if (msg_scrolled > Rows) - /* scroll back to show older messages */ + if (msg_scrolled > Rows) { + // scroll back to show older messages do_more_prompt(c); - else { - msg_didout = FALSE; + } else { + msg_didout = false; c = K_IGNORE; msg_col = cmdmsg_rl ? Columns - 1 : @@ -2097,15 +2097,17 @@ static void msg_puts_display(const char_u *str, int maxlen, int attr, store_sb_text((char_u **)&sb_str, (char_u *)s, attr, &sb_col, true); } - if (*s == '\n') { /* go to next line */ - msg_didout = FALSE; /* remember that line is empty */ - if (cmdmsg_rl) + if (*s == '\n') { // go to next line + msg_didout = false; // remember that line is empty + if (cmdmsg_rl) { msg_col = Columns - 1; - else + } else { msg_col = 0; - if (++msg_row >= Rows) /* safety check */ + } + if (++msg_row >= Rows) { // safety check msg_row = Rows - 1; - } else if (*s == '\r') { /* go to column 0 */ + } + } else if (*s == '\r') { // go to column 0 msg_col = 0; } else if (*s == '\b') { /* go to previous char */ if (msg_col) @@ -2878,10 +2880,10 @@ void repeat_message(void) ui_cursor_goto(msg_row, msg_col); /* put cursor back */ } else if (State == HITRETURN || State == SETWSIZE) { if (msg_row == Rows - 1) { - /* Avoid drawing the "hit-enter" prompt below the previous one, - * overwrite it. Esp. useful when regaining focus and a - * FocusGained autocmd exists but didn't draw anything. */ - msg_didout = FALSE; + // Avoid drawing the "hit-enter" prompt below the previous one, + // overwrite it. Esp. useful when regaining focus and a + // FocusGained autocmd exists but didn't draw anything. + msg_didout = false; msg_col = 0; msg_clr_eos(); } diff --git a/src/nvim/move.c b/src/nvim/move.c index fdcf6bb189..a6afdc27d9 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -129,98 +129,99 @@ void redraw_for_cursorline(win_T *wp) */ void update_topline_redraw(void) { - update_topline(); - if (must_redraw) + update_topline(curwin); + if (must_redraw) { update_screen(0); + } } /* * Update curwin->w_topline to move the cursor onto the screen. */ -void update_topline(void) +void update_topline(win_T *wp) { linenr_T old_topline; int old_topfill; bool check_topline = false; bool check_botline = false; - long *so_ptr = curwin->w_p_so >= 0 ? &curwin->w_p_so : &p_so; + long *so_ptr = wp->w_p_so >= 0 ? &wp->w_p_so : &p_so; long save_so = *so_ptr; // If there is no valid screen and when the window height is zero just use // the cursor line. - if (!default_grid.chars || curwin->w_height_inner == 0) { - curwin->w_topline = curwin->w_cursor.lnum; - curwin->w_botline = curwin->w_topline; - curwin->w_valid |= VALID_BOTLINE|VALID_BOTLINE_AP; - curwin->w_viewport_invalid = true; - curwin->w_scbind_pos = 1; + if (!default_grid.chars || wp->w_height_inner == 0) { + wp->w_topline = wp->w_cursor.lnum; + wp->w_botline = wp->w_topline; + wp->w_valid |= VALID_BOTLINE|VALID_BOTLINE_AP; + wp->w_viewport_invalid = true; + wp->w_scbind_pos = 1; return; } - check_cursor_moved(curwin); - if (curwin->w_valid & VALID_TOPLINE) + check_cursor_moved(wp); + if (wp->w_valid & VALID_TOPLINE) { return; + } // When dragging with the mouse, don't scroll that quickly if (mouse_dragging > 0) { *so_ptr = mouse_dragging - 1; } - old_topline = curwin->w_topline; - old_topfill = curwin->w_topfill; + old_topline = wp->w_topline; + old_topfill = wp->w_topfill; // If the buffer is empty, always set topline to 1. if (BUFEMPTY()) { // special case - file is empty - if (curwin->w_topline != 1) { - redraw_later(curwin, NOT_VALID); + if (wp->w_topline != 1) { + redraw_later(wp, NOT_VALID); } - curwin->w_topline = 1; - curwin->w_botline = 2; - curwin->w_valid |= VALID_BOTLINE|VALID_BOTLINE_AP; - curwin->w_viewport_invalid = true; - curwin->w_scbind_pos = 1; - } - /* - * If the cursor is above or near the top of the window, scroll the window - * to show the line the cursor is in, with 'scrolloff' context. - */ - else { - if (curwin->w_topline > 1) { - /* If the cursor is above topline, scrolling is always needed. - * If the cursor is far below topline and there is no folding, - * scrolling down is never needed. */ - if (curwin->w_cursor.lnum < curwin->w_topline) + wp->w_topline = 1; + wp->w_botline = 2; + wp->w_valid |= VALID_BOTLINE|VALID_BOTLINE_AP; + wp->w_viewport_invalid = true; + wp->w_scbind_pos = 1; + } else { + // If the cursor is above or near the top of the window, scroll the window + // to show the line the cursor is in, with 'scrolloff' context. + if (wp->w_topline > 1) { + // If the cursor is above topline, scrolling is always needed. + // If the cursor is far below topline and there is no folding, + // scrolling down is never needed. + if (wp->w_cursor.lnum < wp->w_topline) { check_topline = true; - else if (check_top_offset()) + } else if (check_top_offset()) { check_topline = true; + } } - /* Check if there are more filler lines than allowed. */ - if (!check_topline && curwin->w_topfill > diff_check_fill(curwin, - curwin->w_topline)) + // Check if there are more filler lines than allowed. + if (!check_topline && wp->w_topfill > diff_check_fill(wp, wp->w_topline)) { check_topline = true; + } if (check_topline) { - int halfheight = curwin->w_height_inner / 2 - 1; + int halfheight = wp->w_height_inner / 2 - 1; if (halfheight < 2) { halfheight = 2; } long n; - if (hasAnyFolding(curwin)) { - /* Count the number of logical lines between the cursor and - * topline + p_so (approximation of how much will be - * scrolled). */ + if (hasAnyFolding(wp)) { + // Count the number of logical lines between the cursor and + // topline + p_so (approximation of how much will be + // scrolled). n = 0; - for (linenr_T lnum = curwin->w_cursor.lnum; - lnum < curwin->w_topline + *so_ptr; lnum++) { + for (linenr_T lnum = wp->w_cursor.lnum; + lnum < wp->w_topline + *so_ptr; lnum++) { n++; // stop at end of file or when we know we are far off - if (lnum >= curbuf->b_ml.ml_line_count || n >= halfheight) { + assert(wp->w_buffer != 0); + if (lnum >= wp->w_buffer->b_ml.ml_line_count || n >= halfheight) { break; } - (void)hasFolding(lnum, NULL, &lnum); + (void)hasFoldingWin(wp, lnum, NULL, &lnum, true, NULL); } } else { - n = curwin->w_topline + *so_ptr - curwin->w_cursor.lnum; + n = wp->w_topline + *so_ptr - wp->w_cursor.lnum; } /* If we weren't very close to begin with, we scroll to put the @@ -233,8 +234,8 @@ void update_topline(void) check_botline = true; } } else { - /* Make sure topline is the first line of a fold. */ - (void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL); + // Make sure topline is the first line of a fold. + (void)hasFoldingWin(wp, wp->w_topline, &wp->w_topline, NULL, true, NULL); check_botline = true; } } @@ -248,35 +249,36 @@ void update_topline(void) * for every small change. */ if (check_botline) { - if (!(curwin->w_valid & VALID_BOTLINE_AP)) - validate_botline(); - - if (curwin->w_botline <= curbuf->b_ml.ml_line_count) { - if (curwin->w_cursor.lnum < curwin->w_botline) { - if (((long)curwin->w_cursor.lnum - >= (long)curwin->w_botline - *so_ptr - || hasAnyFolding(curwin) - )) { + if (!(wp->w_valid & VALID_BOTLINE_AP)) { + validate_botline(wp); + } + + assert(wp->w_buffer != 0); + if (wp->w_botline <= wp->w_buffer->b_ml.ml_line_count) { + if (wp->w_cursor.lnum < wp->w_botline) { + if (((long)wp->w_cursor.lnum + >= (long)wp->w_botline - *so_ptr + || hasAnyFolding(wp))) { lineoff_T loff; /* Cursor is (a few lines) above botline, check if there are * 'scrolloff' window lines below the cursor. If not, need to * scroll. */ - int n = curwin->w_empty_rows; - loff.lnum = curwin->w_cursor.lnum; - /* In a fold go to its last line. */ - (void)hasFolding(loff.lnum, NULL, &loff.lnum); + int n = wp->w_empty_rows; + loff.lnum = wp->w_cursor.lnum; + // In a fold go to its last line. + (void)hasFoldingWin(wp, loff.lnum, NULL, &loff.lnum, true, NULL); loff.fill = 0; - n += curwin->w_filler_rows; + n += wp->w_filler_rows; loff.height = 0; - while (loff.lnum < curwin->w_botline - && (loff.lnum + 1 < curwin->w_botline || loff.fill == 0) + while (loff.lnum < wp->w_botline + && (loff.lnum + 1 < wp->w_botline || loff.fill == 0) ) { n += loff.height; if (n >= *so_ptr) { break; } - botline_forw(&loff); + botline_forw(wp, &loff); } if (n >= *so_ptr) { // sufficient context, no need to scroll @@ -289,23 +291,23 @@ void update_topline(void) } if (check_botline) { long line_count = 0; - if (hasAnyFolding(curwin)) { - /* Count the number of logical lines between the cursor and - * botline - p_so (approximation of how much will be - * scrolled). */ - for (linenr_T lnum = curwin->w_cursor.lnum; - lnum >= curwin->w_botline - *so_ptr; lnum--) { + if (hasAnyFolding(wp)) { + // Count the number of logical lines between the cursor and + // botline - p_so (approximation of how much will be + // scrolled). + for (linenr_T lnum = wp->w_cursor.lnum; + lnum >= wp->w_botline - *so_ptr; lnum--) { line_count++; // stop at end of file or when we know we are far off - if (lnum <= 0 || line_count > curwin->w_height_inner + 1) { + if (lnum <= 0 || line_count > wp->w_height_inner + 1) { break; } (void)hasFolding(lnum, &lnum, NULL); } - } else - line_count = curwin->w_cursor.lnum - curwin->w_botline - + 1 + *so_ptr; - if (line_count <= curwin->w_height_inner + 1) { + } else { + line_count = wp->w_cursor.lnum - wp->w_botline + 1 + *so_ptr; + } + if (line_count <= wp->w_height_inner + 1) { scroll_cursor_bot(scrolljump_value(), false); } else { scroll_cursor_halfway(false); @@ -313,25 +315,25 @@ void update_topline(void) } } } - curwin->w_valid |= VALID_TOPLINE; - curwin->w_viewport_invalid = true; - win_check_anchored_floats(curwin); + wp->w_valid |= VALID_TOPLINE; + wp->w_viewport_invalid = true; + win_check_anchored_floats(wp); /* * Need to redraw when topline changed. */ - if (curwin->w_topline != old_topline - || curwin->w_topfill != old_topfill + if (wp->w_topline != old_topline + || wp->w_topfill != old_topfill ) { dollar_vcol = -1; - if (curwin->w_skipcol != 0) { - curwin->w_skipcol = 0; - redraw_later(curwin, NOT_VALID); + if (wp->w_skipcol != 0) { + wp->w_skipcol = 0; + redraw_later(wp, NOT_VALID); } else { - redraw_later(curwin, VALID); + redraw_later(wp, VALID); } // May need to set w_skipcol when cursor in w_topline. - if (curwin->w_cursor.lnum == curwin->w_topline) { + if (wp->w_cursor.lnum == wp->w_topline) { validate_cursor(); } } @@ -346,7 +348,7 @@ void update_topline_win(win_T* win) { win_T *save_curwin; switch_win(&save_curwin, NULL, win, NULL, true); - update_topline(); + update_topline(curwin); restore_win(save_curwin, NULL, true); } @@ -368,7 +370,7 @@ static int scrolljump_value(void) */ static bool check_top_offset(void) { - long so = get_scrolloff_value(); + long so = get_scrolloff_value(curwin); if (curwin->w_cursor.lnum < curwin->w_topline + so || hasAnyFolding(curwin) ) { @@ -378,7 +380,7 @@ static bool check_top_offset(void) int n = curwin->w_topfill; // always have this context // Count the visible screen lines above the cursor line. while (n < so) { - topline_back(&loff); + topline_back(curwin, &loff); // Stop when included a line above the window. if (loff.lnum < curwin->w_topline || (loff.lnum == curwin->w_topline && loff.fill > 0) @@ -498,10 +500,11 @@ void changed_line_abv_curs_win(win_T *wp) /* * Make sure the value of curwin->w_botline is valid. */ -void validate_botline(void) +void validate_botline(win_T *wp) { - if (!(curwin->w_valid & VALID_BOTLINE)) - comp_botline(curwin); + if (!(wp->w_valid & VALID_BOTLINE)) { + comp_botline(wp); + } } /* @@ -539,8 +542,9 @@ int cursor_valid(void) void validate_cursor(void) { check_cursor_moved(curwin); - if ((curwin->w_valid & (VALID_WCOL|VALID_WROW)) != (VALID_WCOL|VALID_WROW)) - curs_columns(true); + if ((curwin->w_valid & (VALID_WCOL|VALID_WROW)) != (VALID_WCOL|VALID_WROW)) { + curs_columns(curwin, true); + } } /* @@ -720,8 +724,10 @@ int curwin_col_off2(void) // Compute curwin->w_wcol and curwin->w_virtcol. // Also updates curwin->w_wrow and curwin->w_cline_row. // Also updates curwin->w_leftcol. +// @param may_scroll when true, may scroll horizontally void curs_columns( - int may_scroll /* when true, may scroll horizontally */ + win_T *wp, + int may_scroll ) { int n; @@ -729,136 +735,136 @@ void curs_columns( colnr_T startcol; colnr_T endcol; colnr_T prev_skipcol; - long so = get_scrolloff_value(); - long siso = get_sidescrolloff_value(); + long so = get_scrolloff_value(wp); + long siso = get_sidescrolloff_value(wp); /* * First make sure that w_topline is valid (after moving the cursor). */ - update_topline(); + update_topline(wp); // Next make sure that w_cline_row is valid. - if (!(curwin->w_valid & VALID_CROW)) { - curs_rows(curwin); + if (!(wp->w_valid & VALID_CROW)) { + curs_rows(wp); } /* * Compute the number of virtual columns. */ - if (curwin->w_cline_folded) - /* In a folded line the cursor is always in the first column */ - startcol = curwin->w_virtcol = endcol = curwin->w_leftcol; - else - getvvcol(curwin, &curwin->w_cursor, - &startcol, &(curwin->w_virtcol), &endcol); + if (wp->w_cline_folded) { + // In a folded line the cursor is always in the first column + startcol = wp->w_virtcol = endcol = wp->w_leftcol; + } else { + getvvcol(wp, &wp->w_cursor, &startcol, &(wp->w_virtcol), &endcol); + } /* remove '$' from change command when cursor moves onto it */ if (startcol > dollar_vcol) dollar_vcol = -1; - int extra = curwin_col_off(); - curwin->w_wcol = curwin->w_virtcol + extra; + int extra = win_col_off(wp); + wp->w_wcol = wp->w_virtcol + extra; endcol += extra; - /* - * Now compute w_wrow, counting screen lines from w_cline_row. - */ - curwin->w_wrow = curwin->w_cline_row; + // Now compute w_wrow, counting screen lines from w_cline_row. + wp->w_wrow = wp->w_cline_row; - int textwidth = curwin->w_width_inner - extra; + int textwidth = wp->w_width_inner - extra; if (textwidth <= 0) { // No room for text, put cursor in last char of window. - curwin->w_wcol = curwin->w_width_inner - 1; - curwin->w_wrow = curwin->w_height_inner - 1; - } else if (curwin->w_p_wrap - && curwin->w_width_inner != 0 + wp->w_wcol = wp->w_width_inner - 1; + wp->w_wrow = wp->w_height_inner - 1; + } else if (wp->w_p_wrap + && wp->w_width_inner != 0 ) { - width = textwidth + curwin_col_off2(); + width = textwidth + win_col_off2(wp); - // long line wrapping, adjust curwin->w_wrow - if (curwin->w_wcol >= curwin->w_width_inner) { + // long line wrapping, adjust wp->w_wrow + if (wp->w_wcol >= wp->w_width_inner) { // this same formula is used in validate_cursor_col() - n = (curwin->w_wcol - curwin->w_width_inner) / width + 1; - curwin->w_wcol -= n * width; - curwin->w_wrow += n; + n = (wp->w_wcol - wp->w_width_inner) / width + 1; + wp->w_wcol -= n * width; + wp->w_wrow += n; /* When cursor wraps to first char of next line in Insert * mode, the 'showbreak' string isn't shown, backup to first * column */ if (*p_sbr && *get_cursor_pos_ptr() == NUL - && curwin->w_wcol == (int)vim_strsize(p_sbr)) - curwin->w_wcol = 0; + && wp->w_wcol == (int)vim_strsize(p_sbr)) { + wp->w_wcol = 0; + } } - } - /* No line wrapping: compute curwin->w_leftcol if scrolling is on and line - * is not folded. - * If scrolling is off, curwin->w_leftcol is assumed to be 0 */ - else if (may_scroll - && !curwin->w_cline_folded - ) { - /* - * If Cursor is left of the screen, scroll rightwards. - * If Cursor is right of the screen, scroll leftwards - * If we get closer to the edge than 'sidescrolloff', scroll a little - * extra - */ + } else if (may_scroll + && !wp->w_cline_folded + ) { + // No line wrapping: compute wp->w_leftcol if scrolling is on and line + // is not folded. + // If scrolling is off, wp->w_leftcol is assumed to be 0 + + // If Cursor is left of the screen, scroll rightwards. + // If Cursor is right of the screen, scroll leftwards + // If we get closer to the edge than 'sidescrolloff', scroll a little + // extra assert(siso <= INT_MAX); - int off_left = startcol - curwin->w_leftcol - (int)siso; + int off_left = startcol - wp->w_leftcol - (int)siso; int off_right = - endcol - curwin->w_leftcol - curwin->w_width_inner + (int)siso + 1; + endcol - wp->w_leftcol - wp->w_width_inner + (int)siso + 1; if (off_left < 0 || off_right > 0) { int diff = (off_left < 0) ? -off_left: off_right; /* When far off or not enough room on either side, put cursor in * middle of window. */ int new_leftcol; - if (p_ss == 0 || diff >= textwidth / 2 || off_right >= off_left) - new_leftcol = curwin->w_wcol - extra - textwidth / 2; - else { + if (p_ss == 0 || diff >= textwidth / 2 || off_right >= off_left) { + new_leftcol = wp->w_wcol - extra - textwidth / 2; + } else { if (diff < p_ss) { assert(p_ss <= INT_MAX); diff = (int)p_ss; } - if (off_left < 0) - new_leftcol = curwin->w_leftcol - diff; - else - new_leftcol = curwin->w_leftcol + diff; + if (off_left < 0) { + new_leftcol = wp->w_leftcol - diff; + } else { + new_leftcol = wp->w_leftcol + diff; + } } if (new_leftcol < 0) new_leftcol = 0; - if (new_leftcol != (int)curwin->w_leftcol) { - curwin->w_leftcol = new_leftcol; - win_check_anchored_floats(curwin); - // screen has to be redrawn with new curwin->w_leftcol - redraw_later(curwin, NOT_VALID); + if (new_leftcol != (int)wp->w_leftcol) { + wp->w_leftcol = new_leftcol; + win_check_anchored_floats(wp); + // screen has to be redrawn with new wp->w_leftcol + redraw_later(wp, NOT_VALID); } } - curwin->w_wcol -= curwin->w_leftcol; - } else if (curwin->w_wcol > (int)curwin->w_leftcol) - curwin->w_wcol -= curwin->w_leftcol; - else - curwin->w_wcol = 0; + wp->w_wcol -= wp->w_leftcol; + } else if (wp->w_wcol > (int)wp->w_leftcol) { + wp->w_wcol -= wp->w_leftcol; + } else { + wp->w_wcol = 0; + } /* Skip over filler lines. At the top use w_topfill, there * may be some filler lines above the window. */ - if (curwin->w_cursor.lnum == curwin->w_topline) - curwin->w_wrow += curwin->w_topfill; - else - curwin->w_wrow += diff_check_fill(curwin, curwin->w_cursor.lnum); + if (wp->w_cursor.lnum == wp->w_topline) { + wp->w_wrow += wp->w_topfill; + } else { + wp->w_wrow += diff_check_fill(wp, wp->w_cursor.lnum); + } - prev_skipcol = curwin->w_skipcol; + prev_skipcol = wp->w_skipcol; int plines = 0; - if ((curwin->w_wrow >= curwin->w_height_inner + if ((wp->w_wrow >= wp->w_height_inner || ((prev_skipcol > 0 - || curwin->w_wrow + so >= curwin->w_height_inner) + || wp->w_wrow + so >= wp->w_height_inner) && (plines = - plines_win_nofill(curwin, curwin->w_cursor.lnum, false)) - 1 - >= curwin->w_height_inner)) - && curwin->w_height_inner != 0 - && curwin->w_cursor.lnum == curwin->w_topline + plines_win_nofill(wp, wp->w_cursor.lnum, false)) - 1 + >= wp->w_height_inner)) + && wp->w_height_inner != 0 + && wp->w_cursor.lnum == wp->w_topline && width > 0 - && curwin->w_width_inner != 0 + && wp->w_width_inner != 0 ) { /* Cursor past end of screen. Happens with a single line that does * not fit on screen. Find a skipcol to show the text around the @@ -867,87 +873,88 @@ void curs_columns( * 2: Less than "p_so" lines below * 3: both of them */ extra = 0; - if (curwin->w_skipcol + so * width > curwin->w_virtcol) { + if (wp->w_skipcol + so * width > wp->w_virtcol) { extra = 1; } // Compute last display line of the buffer line that we want at the // bottom of the window. if (plines == 0) { - plines = plines_win(curwin, curwin->w_cursor.lnum, false); + plines = plines_win(wp, wp->w_cursor.lnum, false); } plines--; - if (plines > curwin->w_wrow + so) { + if (plines > wp->w_wrow + so) { assert(so <= INT_MAX); - n = curwin->w_wrow + (int)so; + n = wp->w_wrow + (int)so; } else { n = plines; } - if ((colnr_T)n >= curwin->w_height_inner + curwin->w_skipcol / width) { + if ((colnr_T)n >= wp->w_height_inner + wp->w_skipcol / width) { extra += 2; } if (extra == 3 || plines < so * 2) { // not enough room for 'scrolloff', put cursor in the middle - n = curwin->w_virtcol / width; - if (n > curwin->w_height_inner / 2) { - n -= curwin->w_height_inner / 2; + n = wp->w_virtcol / width; + if (n > wp->w_height_inner / 2) { + n -= wp->w_height_inner / 2; } else { n = 0; } // don't skip more than necessary - if (n > plines - curwin->w_height_inner + 1) { - n = plines - curwin->w_height_inner + 1; + if (n > plines - wp->w_height_inner + 1) { + n = plines - wp->w_height_inner + 1; } - curwin->w_skipcol = n * width; + wp->w_skipcol = n * width; } else if (extra == 1) { // less then 'scrolloff' lines above, decrease skipcol assert(so <= INT_MAX); - extra = (curwin->w_skipcol + (int)so * width - curwin->w_virtcol + extra = (wp->w_skipcol + (int)so * width - wp->w_virtcol + width - 1) / width; if (extra > 0) { - if ((colnr_T)(extra * width) > curwin->w_skipcol) - extra = curwin->w_skipcol / width; - curwin->w_skipcol -= extra * width; + if ((colnr_T)(extra * width) > wp->w_skipcol) { + extra = wp->w_skipcol / width; + } + wp->w_skipcol -= extra * width; } } else if (extra == 2) { // less then 'scrolloff' lines below, increase skipcol - endcol = (n - curwin->w_height_inner + 1) * width; - while (endcol > curwin->w_virtcol) { + endcol = (n - wp->w_height_inner + 1) * width; + while (endcol > wp->w_virtcol) { endcol -= width; } - if (endcol > curwin->w_skipcol) { - curwin->w_skipcol = endcol; + if (endcol > wp->w_skipcol) { + wp->w_skipcol = endcol; } } - curwin->w_wrow -= curwin->w_skipcol / width; - if (curwin->w_wrow >= curwin->w_height_inner) { + wp->w_wrow -= wp->w_skipcol / width; + if (wp->w_wrow >= wp->w_height_inner) { // small window, make sure cursor is in it - extra = curwin->w_wrow - curwin->w_height_inner + 1; - curwin->w_skipcol += extra * width; - curwin->w_wrow -= extra; + extra = wp->w_wrow - wp->w_height_inner + 1; + wp->w_skipcol += extra * width; + wp->w_wrow -= extra; } // extra could be either positive or negative - extra = ((int)prev_skipcol - (int)curwin->w_skipcol) / width; - win_scroll_lines(curwin, 0, extra); + extra = ((int)prev_skipcol - (int)wp->w_skipcol) / width; + win_scroll_lines(wp, 0, extra); } else { - curwin->w_skipcol = 0; + wp->w_skipcol = 0; } - if (prev_skipcol != curwin->w_skipcol) { - redraw_later(curwin, NOT_VALID); + if (prev_skipcol != wp->w_skipcol) { + redraw_later(wp, NOT_VALID); } - /* Redraw when w_virtcol changes and 'cursorcolumn' is set */ - if (curwin->w_p_cuc && (curwin->w_valid & VALID_VIRTCOL) == 0 + // Redraw when w_virtcol changes and 'cursorcolumn' is set + if (wp->w_p_cuc && (wp->w_valid & VALID_VIRTCOL) == 0 && !pum_visible()) { - redraw_later(curwin, SOME_VALID); + redraw_later(wp, SOME_VALID); } // now w_leftcol is valid, avoid check_cursor_moved() thinking otherwise - curwin->w_valid_leftcol = curwin->w_leftcol; + wp->w_valid_leftcol = wp->w_leftcol; - curwin->w_valid |= VALID_WCOL|VALID_WROW|VALID_VIRTCOL; + wp->w_valid |= VALID_WCOL|VALID_WROW|VALID_VIRTCOL; } /// Compute the screen position of text character at "pos" in window "wp" @@ -1231,7 +1238,7 @@ void scrolldown_clamp(void) end_row += curwin->w_cline_height - 1 - curwin->w_virtcol / curwin->w_width_inner; } - if (end_row < curwin->w_height_inner - get_scrolloff_value()) { + if (end_row < curwin->w_height_inner - get_scrolloff_value(curwin)) { if (can_fill) { ++curwin->w_topfill; check_topfill(curwin, true); @@ -1271,7 +1278,7 @@ void scrollup_clamp(void) validate_virtcol(); start_row -= curwin->w_virtcol / curwin->w_width_inner; } - if (start_row >= get_scrolloff_value()) { + if (start_row >= get_scrolloff_value(curwin)) { if (curwin->w_topfill > 0) { curwin->w_topfill--; } else { @@ -1289,22 +1296,22 @@ void scrollup_clamp(void) * Returns the height of the added line in "lp->height". * Lines above the first one are incredibly high: MAXCOL. */ -static void topline_back(lineoff_T *lp) +static void topline_back(win_T *wp, lineoff_T *lp) { - if (lp->fill < diff_check_fill(curwin, lp->lnum)) { - /* Add a filler line. */ - ++lp->fill; + if (lp->fill < diff_check_fill(wp, lp->lnum)) { + // Add a filler line + lp->fill++; lp->height = 1; } else { --lp->lnum; lp->fill = 0; - if (lp->lnum < 1) + if (lp->lnum < 1) { lp->height = MAXCOL; - else if (hasFolding(lp->lnum, &lp->lnum, NULL)) - /* Add a closed fold */ + } else if (hasFolding(lp->lnum, &lp->lnum, NULL)) { + // Add a closed fold lp->height = 1; - else { - lp->height = plines_nofill(lp->lnum); + } else { + lp->height = plines_win_nofill(wp, lp->lnum, true); } } } @@ -1315,22 +1322,23 @@ static void topline_back(lineoff_T *lp) * Returns the height of the added line in "lp->height". * Lines below the last one are incredibly high. */ -static void botline_forw(lineoff_T *lp) +static void botline_forw(win_T *wp, lineoff_T *lp) { - if (lp->fill < diff_check_fill(curwin, lp->lnum + 1)) { - /* Add a filler line. */ - ++lp->fill; + if (lp->fill < diff_check_fill(wp, lp->lnum + 1)) { + // Add a filler line. + lp->fill++; lp->height = 1; } else { ++lp->lnum; lp->fill = 0; - if (lp->lnum > curbuf->b_ml.ml_line_count) { + assert(wp->w_buffer != 0); + if (lp->lnum > wp->w_buffer->b_ml.ml_line_count) { lp->height = MAXCOL; - } else if (hasFolding(lp->lnum, NULL, &lp->lnum)) { + } else if (hasFoldingWin(wp, lp->lnum, NULL, &lp->lnum, true, NULL)) { // Add a closed fold lp->height = 1; } else { - lp->height = plines_nofill(lp->lnum); + lp->height = plines_win_nofill(wp, lp->lnum, true); } } } @@ -1374,7 +1382,7 @@ void scroll_cursor_top(int min_scroll, int always) linenr_T old_topline = curwin->w_topline; linenr_T old_topfill = curwin->w_topfill; linenr_T new_topline; - int off = (int)get_scrolloff_value(); + int off = (int)get_scrolloff_value(curwin); if (mouse_dragging > 0) off = mouse_dragging - 1; @@ -1518,7 +1526,7 @@ void scroll_cursor_bot(int min_scroll, int set_topbot) int old_valid = curwin->w_valid; int old_empty_rows = curwin->w_empty_rows; linenr_T cln = curwin->w_cursor.lnum; // Cursor Line Number - long so = get_scrolloff_value(); + long so = get_scrolloff_value(curwin); if (set_topbot) { used = 0; @@ -1528,7 +1536,7 @@ void scroll_cursor_bot(int min_scroll, int set_topbot) curwin->w_topline > 1; curwin->w_topline = loff.lnum) { loff.lnum = curwin->w_topline; - topline_back(&loff); + topline_back(curwin, &loff); if (loff.height == MAXCOL || used + loff.height > curwin->w_height_inner) { break; @@ -1542,8 +1550,9 @@ void scroll_cursor_bot(int min_scroll, int set_topbot) || curwin->w_topfill != old_topfill ) curwin->w_valid &= ~(VALID_WROW|VALID_CROW); - } else - validate_botline(); + } else { + validate_botline(curwin); + } /* The lines of the cursor line itself are always used. */ used = plines_nofill(cln); @@ -1586,8 +1595,8 @@ void scroll_cursor_bot(int min_scroll, int set_topbot) break; } - /* Add one line above */ - topline_back(&loff); + // Add one line above + topline_back(curwin, &loff); if (loff.height == MAXCOL) { used = MAXCOL; } else { @@ -1609,8 +1618,8 @@ void scroll_cursor_bot(int min_scroll, int set_topbot) } if (boff.lnum < curbuf->b_ml.ml_line_count) { - /* Add one line below */ - botline_forw(&boff); + // Add one line below + botline_forw(curwin, &boff); used += boff.height; if (used > curwin->w_height_inner) { break; @@ -1647,7 +1656,7 @@ void scroll_cursor_bot(int min_scroll, int set_topbot) boff.lnum = curwin->w_topline - 1; int i; for (i = 0; i < scrolled && boff.lnum < curwin->w_botline; ) { - botline_forw(&boff); + botline_forw(curwin, &boff); i += boff.height; ++line_count; } @@ -1701,7 +1710,7 @@ void scroll_cursor_halfway(int atend) while (topline > 1) { if (below <= above) { /* add a line below the cursor first */ if (boff.lnum < curbuf->b_ml.ml_line_count) { - botline_forw(&boff); + botline_forw(curwin, &boff); used += boff.height; if (used > curwin->w_height_inner) { break; @@ -1714,12 +1723,13 @@ void scroll_cursor_halfway(int atend) } } - if (below > above) { /* add a line above the cursor */ - topline_back(&loff); - if (loff.height == MAXCOL) + if (below > above) { // add a line above the cursor + topline_back(curwin, &loff); + if (loff.height == MAXCOL) { used = MAXCOL; - else + } else { used += loff.height; + } if (used > curwin->w_height_inner) { break; } @@ -1751,8 +1761,8 @@ void cursor_correct(void) * How many lines we would like to have above/below the cursor depends on * whether the first/last line of the file is on screen. */ - int above_wanted = (int)get_scrolloff_value(); - int below_wanted = (int)get_scrolloff_value(); + int above_wanted = (int)get_scrolloff_value(curwin); + int below_wanted = (int)get_scrolloff_value(curwin); if (mouse_dragging > 0) { above_wanted = mouse_dragging - 1; below_wanted = mouse_dragging - 1; @@ -1764,7 +1774,7 @@ void cursor_correct(void) below_wanted = max_off; } } - validate_botline(); + validate_botline(curwin); if (curwin->w_botline == curbuf->b_ml.ml_line_count + 1 && mouse_dragging == 0) { below_wanted = 0; @@ -1848,21 +1858,19 @@ int onepage(Direction dir, long count) int retval = OK; lineoff_T loff; linenr_T old_topline = curwin->w_topline; - long so = get_scrolloff_value(); + long so = get_scrolloff_value(curwin); if (curbuf->b_ml.ml_line_count == 1) { /* nothing to do */ beep_flush(); return FAIL; } - for (; count > 0; --count) { - validate_botline(); - /* - * It's an error to move a page up when the first line is already on - * the screen. It's an error to move a page down when the last line - * is on the screen and the topline is 'scrolloff' lines from the - * last line. - */ + for (; count > 0; count--) { + validate_botline(curwin); + // It's an error to move a page up when the first line is already on + // the screen. It's an error to move a page down when the last line + // is on the screen and the topline is 'scrolloff' lines from the + // last line. if (dir == FORWARD ? ((curwin->w_topline >= curbuf->b_ml.ml_line_count - so) && curwin->w_botline > curbuf->b_ml.ml_line_count) @@ -1945,11 +1953,12 @@ int onepage(Direction dir, long count) * at the bottom of the window. */ n = 0; while (n <= curwin->w_height_inner && loff.lnum >= 1) { - topline_back(&loff); - if (loff.height == MAXCOL) + topline_back(curwin, &loff); + if (loff.height == MAXCOL) { n = MAXCOL; - else + } else { n += loff.height; + } } if (loff.lnum < 1) { /* at begin of file */ curwin->w_topline = 1; @@ -1958,11 +1967,11 @@ int onepage(Direction dir, long count) } else { /* Go two lines forward again. */ topline_botline(&loff); - botline_forw(&loff); - botline_forw(&loff); + botline_forw(curwin, &loff); + botline_forw(curwin, &loff); botline_topline(&loff); - /* We're at the wrong end of a fold now. */ - (void)hasFolding(loff.lnum, &loff.lnum, NULL); + // We're at the wrong end of a fold now. + (void)hasFoldingWin(curwin, loff.lnum, &loff.lnum, NULL, true, NULL); /* Always scroll at least one line. Avoid getting stuck on * very long lines. */ @@ -2046,10 +2055,11 @@ static void get_scroll_overlap(lineoff_T *lp, int dir) return; /* no overlap */ lineoff_T loff0 = *lp; - if (dir > 0) - botline_forw(lp); - else - topline_back(lp); + if (dir > 0) { + botline_forw(curwin, lp); + } else { + topline_back(curwin, lp); + } int h2 = lp->height; if (h2 == MAXCOL || h2 + h1 > min_height) { *lp = loff0; /* no overlap */ @@ -2057,10 +2067,11 @@ static void get_scroll_overlap(lineoff_T *lp, int dir) } lineoff_T loff1 = *lp; - if (dir > 0) - botline_forw(lp); - else - topline_back(lp); + if (dir > 0) { + botline_forw(curwin, lp); + } else { + topline_back(curwin, lp); + } int h3 = lp->height; if (h3 == MAXCOL || h3 + h2 > min_height) { *lp = loff0; /* no overlap */ @@ -2068,10 +2079,11 @@ static void get_scroll_overlap(lineoff_T *lp, int dir) } lineoff_T loff2 = *lp; - if (dir > 0) - botline_forw(lp); - else - topline_back(lp); + if (dir > 0) { + botline_forw(curwin, lp); + } else { + topline_back(curwin, lp); + } int h4 = lp->height; if (h4 == MAXCOL || h4 + h3 + h2 > min_height || h3 + h2 + h1 > min_height) *lp = loff1; /* 1 line overlap */ @@ -2094,8 +2106,8 @@ void halfpage(bool flag, linenr_T Prenum) int n = curwin->w_p_scr <= curwin->w_height_inner ? (int)curwin->w_p_scr : curwin->w_height_inner; - update_topline(); - validate_botline(); + update_topline(curwin); + validate_botline(curwin); int room = curwin->w_empty_rows + curwin->w_filler_rows; if (flag) { /* @@ -2255,7 +2267,7 @@ void do_check_cursorbind(void) // Only scroll when 'scrollbind' hasn't done this. if (!curwin->w_p_scb) { - update_topline(); + update_topline(curwin); } curwin->w_redr_status = true; } diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 68ef4cd41e..a0b439ac45 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -377,6 +377,10 @@ static void request_event(void **argv) Channel *channel = e->channel; MsgpackRpcRequestHandler handler = e->handler; Error error = ERROR_INIT; + if (channel->rpc.closed) { + // channel was closed, abort any pending requests + goto free_ret; + } Object result = handler.fn(channel->id, e->args, &error); if (e->type == kMessageTypeRequest || ERROR_SET(&error)) { // Send the response. @@ -391,6 +395,8 @@ static void request_event(void **argv) } else { api_free_object(result); } + +free_ret: api_free_array(e->args); channel_decref(channel); xfree(e); diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 0293bb4a73..f93d772068 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -168,7 +168,7 @@ static const struct nv_cmd { { NL, nv_down, 0, false }, { Ctrl_K, nv_error, 0, 0 }, { Ctrl_L, nv_clear, 0, 0 }, - { Ctrl_M, nv_down, 0, true }, + { CAR, nv_down, 0, true }, { Ctrl_N, nv_down, NV_STS, false }, { Ctrl_O, nv_ctrlo, 0, 0 }, { Ctrl_P, nv_up, NV_STS, false }, @@ -1261,7 +1261,7 @@ static void normal_redraw(NormalState *s) { // Before redrawing, make sure w_topline is correct, and w_leftcol // if lines don't wrap, and w_skipcol if lines wrap. - update_topline(); + update_topline(curwin); validate_cursor(); // If the cursor moves horizontally when 'concealcursor' is active, then the @@ -1341,7 +1341,7 @@ static int normal_check(VimState *state) } else if (do_redraw || stuff_empty()) { // Need to make sure w_topline and w_leftcol are correct before // normal_check_window_scrolled() is called. - update_topline(); + update_topline(curwin); normal_check_cursor_moved(s); normal_check_text_changed(s); @@ -2629,7 +2629,7 @@ do_mouse ( /* Set global flag that we are extending the Visual area with mouse * dragging; temporarily minimize 'scrolloff'. */ - if (VIsual_active && is_drag && get_scrolloff_value()) { + if (VIsual_active && is_drag && get_scrolloff_value(curwin)) { // In the very first line, allow scrolling one line if (mouse_row == 0) { mouse_dragging = 2; @@ -3052,57 +3052,57 @@ static bool find_is_eval_item( return false; } -/* - * Find the identifier under or to the right of the cursor. - * "find_type" can have one of three values: - * FIND_IDENT: find an identifier (keyword) - * FIND_STRING: find any non-white string - * FIND_IDENT + FIND_STRING: find any non-white string, identifier preferred. - * FIND_EVAL: find text useful for C program debugging - * - * There are three steps: - * 1. Search forward for the start of an identifier/string. Doesn't move if - * already on one. - * 2. Search backward for the start of this identifier/string. - * This doesn't match the real Vi but I like it a little better and it - * shouldn't bother anyone. - * 3. Search forward to the end of this identifier/string. - * When FIND_IDENT isn't defined, we backup until a blank. - * - * Returns the length of the string, or zero if no string is found. - * If a string is found, a pointer to the string is put in "*string". This - * string is not always NUL terminated. - */ -size_t find_ident_under_cursor(char_u **string, int find_type) +// Find the identifier under or to the right of the cursor. +// "find_type" can have one of three values: +// FIND_IDENT: find an identifier (keyword) +// FIND_STRING: find any non-white text +// FIND_IDENT + FIND_STRING: find any non-white text, identifier preferred. +// FIND_EVAL: find text useful for C program debugging +// +// There are three steps: +// 1. Search forward for the start of an identifier/text. Doesn't move if +// already on one. +// 2. Search backward for the start of this identifier/text. +// This doesn't match the real Vi but I like it a little better and it +// shouldn't bother anyone. +// 3. Search forward to the end of this identifier/text. +// When FIND_IDENT isn't defined, we backup until a blank. +// +// Returns the length of the text, or zero if no text is found. +// If text is found, a pointer to the text is put in "*text". This +// points into the current buffer line and is not always NUL terminated. +size_t find_ident_under_cursor(char_u **text, int find_type) + FUNC_ATTR_NONNULL_ARG(1) { return find_ident_at_pos(curwin, curwin->w_cursor.lnum, - curwin->w_cursor.col, string, find_type); + curwin->w_cursor.col, text, NULL, find_type); } /* * Like find_ident_under_cursor(), but for any window and any position. * However: Uses 'iskeyword' from the current window!. */ -size_t find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol, - char_u **string, int find_type) -{ - char_u *ptr; - int col = 0; /* init to shut up GCC */ +size_t find_ident_at_pos( + win_T *wp, + linenr_T lnum, + colnr_T startcol, + char_u **text, + int *textcol, // column where "text" starts, can be NULL + int find_type) + FUNC_ATTR_NONNULL_ARG(1, 4) +{ + int col = 0; // init to shut up GCC int i; int this_class = 0; int prev_class; int prevcol; int bn = 0; // bracket nesting - /* - * if i == 0: try to find an identifier - * if i == 1: try to find any non-white string - */ - ptr = ml_get_buf(wp->w_buffer, lnum, false); - for (i = (find_type & FIND_IDENT) ? 0 : 1; i < 2; ++i) { - /* - * 1. skip to start of identifier/string - */ + // if i == 0: try to find an identifier + // if i == 1: try to find any non-white text + char_u *ptr = ml_get_buf(wp->w_buffer, lnum, false); + for (i = (find_type & FIND_IDENT) ? 0 : 1; i < 2; i++) { + // 1. skip to start of identifier/text col = startcol; while (ptr[col] != NUL) { // Stop at a ']' to evaluate "a[x]". @@ -3120,7 +3120,7 @@ size_t find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol, bn = ptr[col] == ']'; // - // 2. Back up to start of identifier/string. + // 2. Back up to start of identifier/text. // // Remember class of character under cursor. if ((find_type & FIND_EVAL) && ptr[col] == ']') { @@ -3143,7 +3143,7 @@ size_t find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol, col = prevcol; } - // If we don't want just any old string, or we've found an + // If we don't want just any old text, or we've found an // identifier, stop searching. if (this_class > 2) { this_class = 2; @@ -3154,7 +3154,7 @@ size_t find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol, } if (ptr[col] == NUL || (i == 0 && this_class != 2)) { - // Didn't find an identifier or string. + // Didn't find an identifier or text. if (find_type & FIND_STRING) { EMSG(_("E348: No string under cursor")); } else { @@ -3163,11 +3163,12 @@ size_t find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol, return 0; } ptr += col; - *string = ptr; + *text = ptr; + if (textcol != NULL) { + *textcol = col; + } - /* - * 3. Find the end if the identifier/string. - */ + // 3. Find the end if the identifier/text. bn = 0; startcol -= col; col = 0; @@ -4135,7 +4136,7 @@ void scroll_redraw(int up, long count) scrollup(count, true) : scrolldown(count, true); - if (get_scrolloff_value()) { + if (get_scrolloff_value(curwin)) { // Adjust the cursor position for 'scrolloff'. Mark w_topline as // valid, otherwise the screen jumps back at the end of the file. cursor_correct(); @@ -4185,7 +4186,7 @@ static void nv_zet(cmdarg_T *cap) int old_fen = curwin->w_p_fen; bool undo = false; - int l_p_siso = (int)get_sidescrolloff_value(); + int l_p_siso = (int)get_sidescrolloff_value(curwin); assert(l_p_siso <= INT_MAX); if (ascii_isdigit(nchar)) { @@ -4253,12 +4254,13 @@ dozet: /* "z+", "z<CR>" and "zt": put cursor at top of screen */ case '+': if (cap->count0 == 0) { - /* No count given: put cursor at the line below screen */ - validate_botline(); /* make sure w_botline is valid */ - if (curwin->w_botline > curbuf->b_ml.ml_line_count) + // No count given: put cursor at the line below screen + validate_botline(curwin); // make sure w_botline is valid + if (curwin->w_botline > curbuf->b_ml.ml_line_count) { curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; - else + } else { curwin->w_cursor.lnum = curwin->w_botline; + } } FALLTHROUGH; case NL: @@ -5053,7 +5055,7 @@ static void nv_scroll(cmdarg_T *cap) setpcmark(); if (cap->cmdchar == 'L') { - validate_botline(); /* make sure curwin->w_botline is valid */ + validate_botline(curwin); // make sure curwin->w_botline is valid curwin->w_cursor.lnum = curwin->w_botline - 1; if (cap->count1 - 1 >= curwin->w_cursor.lnum) curwin->w_cursor.lnum = 1; @@ -5074,7 +5076,7 @@ static void nv_scroll(cmdarg_T *cap) /* Don't count filler lines above the window. */ used -= diff_check_fill(curwin, curwin->w_topline) - curwin->w_topfill; - validate_botline(); // make sure w_empty_rows is valid + 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 @@ -6653,16 +6655,15 @@ static void nv_g_cmd(cmdarg_T *cap) VIsual = curwin->w_cursor; curwin->w_cursor = tpos; check_cursor(); - update_topline(); - /* - * When called from normal "g" command: start Select mode when - * 'selectmode' contains "cmd". When called for K_SELECT, always - * start Select mode. - */ - if (cap->arg) + update_topline(curwin); + // When called from normal "g" command: start Select mode when + // 'selectmode' contains "cmd". When called for K_SELECT, always + // start Select mode. + if (cap->arg) { VIsual_select = true; - else + } else { may_start_select('c'); + } setmouse(); redraw_curbuf_later(INVERTED); showmode(); diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 40dd5f0b5c..052b07ed44 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -1197,7 +1197,13 @@ int insert_reg( retval = FAIL; } else { for (size_t i = 0; i < reg->y_size; i++) { - stuffescaped((const char *)reg->y_array[i], literally); + if (regname == '-') { + AppendCharToRedobuff(Ctrl_R); + AppendCharToRedobuff(regname); + do_put(regname, NULL, BACKWARD, 1L, PUT_CURSEND); + } else { + stuffescaped((const char *)reg->y_array[i], literally); + } // Insert a newline between lines and after last line if // y_type is kMTLineWise. if (reg->y_type == kMTLineWise || i < reg->y_size - 1) { @@ -1683,6 +1689,7 @@ int op_delete(oparg_T *oap) (int)oap->line_count-1, n, deleted_bytes, 0, 0, 0, kExtmarkUndo); } + auto_format(false, true); } msgmore(curbuf->b_ml.ml_line_count - old_lcount); @@ -3547,15 +3554,21 @@ void ex_display(exarg_T *eap) int name; char_u *arg = eap->arg; int clen; + char_u type[2]; if (arg != NULL && *arg == NUL) arg = NULL; int attr = HL_ATTR(HLF_8); - /* Highlight title */ - MSG_PUTS_TITLE(_("\n--- Registers ---")); + // Highlight title + msg_puts_title(_("\nType Name Content")); for (int i = -1; i < NUM_REGISTERS && !got_int; i++) { name = get_register_name(i); + switch (get_reg_type(name, NULL)) { + case kMTLineWise: type[0] = 'l'; break; + case kMTCharWise: type[0] = 'c'; break; + default: type[0] = 'b'; break; + } if (arg != NULL && vim_strchr(arg, name) == NULL) { continue; /* did not ask for this register */ @@ -3580,11 +3593,14 @@ void ex_display(exarg_T *eap) if (yb->y_array != NULL) { msg_putchar('\n'); + msg_puts(" "); + msg_putchar(type[0]); + msg_puts(" "); msg_putchar('"'); msg_putchar(name); MSG_PUTS(" "); - int n = Columns - 6; + int n = Columns - 11; for (size_t j = 0; j < yb->y_size && n > 1; j++) { if (j) { MSG_PUTS_ATTR("^J", attr); @@ -3609,8 +3625,8 @@ void ex_display(exarg_T *eap) */ if ((p = get_last_insert()) != NULL && (arg == NULL || vim_strchr(arg, '.') != NULL) && !got_int) { - MSG_PUTS("\n\". "); - dis_msg(p, TRUE); + msg_puts("\n c \". "); + dis_msg(p, true); } /* @@ -3618,8 +3634,8 @@ void ex_display(exarg_T *eap) */ if (last_cmdline != NULL && (arg == NULL || vim_strchr(arg, ':') != NULL) && !got_int) { - MSG_PUTS("\n\": "); - dis_msg(last_cmdline, FALSE); + msg_puts("\n c \": "); + dis_msg(last_cmdline, false); } /* @@ -3627,8 +3643,8 @@ void ex_display(exarg_T *eap) */ if (curbuf->b_fname != NULL && (arg == NULL || vim_strchr(arg, '%') != NULL) && !got_int) { - MSG_PUTS("\n\"% "); - dis_msg(curbuf->b_fname, FALSE); + msg_puts("\n c \"% "); + dis_msg(curbuf->b_fname, false); } /* @@ -3639,8 +3655,8 @@ void ex_display(exarg_T *eap) linenr_T dummy; if (buflist_name_nr(0, &fname, &dummy) != FAIL) { - MSG_PUTS("\n\"# "); - dis_msg(fname, FALSE); + msg_puts("\n c \"# "); + dis_msg(fname, false); } } @@ -3649,8 +3665,8 @@ void ex_display(exarg_T *eap) */ if (last_search_pat() != NULL && (arg == NULL || vim_strchr(arg, '/') != NULL) && !got_int) { - MSG_PUTS("\n\"/ "); - dis_msg(last_search_pat(), FALSE); + msg_puts("\n c \"/ "); + dis_msg(last_search_pat(), false); } /* @@ -3658,8 +3674,8 @@ void ex_display(exarg_T *eap) */ if (expr_line != NULL && (arg == NULL || vim_strchr(arg, '=') != NULL) && !got_int) { - MSG_PUTS("\n\"= "); - dis_msg(expr_line, FALSE); + msg_puts("\n c \"= "); + dis_msg(expr_line, false); } } @@ -3669,9 +3685,10 @@ void ex_display(exarg_T *eap) */ static void dis_msg( - char_u *p, - int skip_esc /* if TRUE, ignore trailing ESC */ + const char_u *p, + bool skip_esc // if true, ignore trailing ESC ) + FUNC_ATTR_NONNULL_ALL { int n; int l; diff --git a/src/nvim/option.c b/src/nvim/option.c index 7cf8412269..d60c8bc01c 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -320,7 +320,7 @@ static char *(p_scl_values[]) = { "yes", "no", "auto", "auto:1", "auto:2", "auto:3", "auto:4", "auto:5", "auto:6", "auto:7", "auto:8", "auto:9", "yes:1", "yes:2", "yes:3", "yes:4", "yes:5", "yes:6", "yes:7", "yes:8", "yes:9", "number", NULL }; -static char *(p_fdc_values[]) = { "auto:1", "auto:2", +static char *(p_fdc_values[]) = { "auto", "auto:1", "auto:2", "auto:3", "auto:4", "auto:5", "auto:6", "auto:7", "auto:8", "auto:9", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", NULL }; @@ -4338,6 +4338,7 @@ static char *set_num_option(int opt_idx, char_u *varp, long value, char buf_old[NUMBUFLEN]; char buf_new[NUMBUFLEN]; char buf_type[7]; + vim_snprintf(buf_old, ARRAY_SIZE(buf_old), "%ld", old_value); vim_snprintf(buf_new, ARRAY_SIZE(buf_new), "%ld", value); vim_snprintf(buf_type, ARRAY_SIZE(buf_type), "%s", @@ -7159,20 +7160,20 @@ dict_T *get_winbuf_options(const int bufopt) /// Return the effective 'scrolloff' value for the current window, using the /// global value when appropriate. -long get_scrolloff_value(void) +long get_scrolloff_value(win_T *wp) { // Disallow scrolloff in terminal-mode. #11915 if (State & TERM_FOCUS) { return 0; } - return curwin->w_p_so < 0 ? p_so : curwin->w_p_so; + return wp->w_p_so < 0 ? p_so : wp->w_p_so; } /// Return the effective 'sidescrolloff' value for the current window, using the /// global value when appropriate. -long get_sidescrolloff_value(void) +long get_sidescrolloff_value(win_T *wp) { - return curwin->w_p_siso < 0 ? p_siso : curwin->w_p_siso; + return wp->w_p_siso < 0 ? p_siso : wp->w_p_siso; } Dictionary get_vimoption(String name, Error *err) diff --git a/src/nvim/popupmnu.c b/src/nvim/popupmnu.c index 551a650045..aef7ffa397 100644 --- a/src/nvim/popupmnu.c +++ b/src/nvim/popupmnu.c @@ -809,7 +809,7 @@ static int pum_set_selected(int n, int repeat) no_u_sync++; win_enter(curwin_save, true); no_u_sync--; - update_topline(); + update_topline(curwin); } // Update the screen before drawing the popup menu. diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 7fdc998e20..aeac6e4905 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -3696,7 +3696,7 @@ void ex_copen(exarg_T *eap) curwin->w_cursor.lnum = lnum; curwin->w_cursor.col = 0; check_cursor(); - update_topline(); // scroll to show the line + update_topline(curwin); // scroll to show the line } // Move the cursor in the quickfix window to "lnum". @@ -3710,7 +3710,7 @@ static void qf_win_goto(win_T *win, linenr_T lnum) curwin->w_cursor.col = 0; curwin->w_cursor.coladd = 0; curwin->w_curswant = 0; - update_topline(); // scroll to show the line + update_topline(curwin); // scroll to show the line redraw_later(curwin, VALID); curwin->w_redr_status = true; // update ruler curwin = old_curwin; @@ -3824,17 +3824,21 @@ static buf_T *qf_find_buf(qf_info_T *qi) return NULL; } -/// Update the w:quickfix_title variable in the quickfix/location list window +/// Update the w:quickfix_title variable in the quickfix/location list window in +/// all the tab pages. static void qf_update_win_titlevar(qf_info_T *qi) + FUNC_ATTR_NONNULL_ALL { - win_T *win; + qf_list_T *const qfl = qf_get_curlist(qi); + win_T *const save_curwin = curwin; - if ((win = qf_find_win(qi)) != NULL) { - win_T *curwin_save = curwin; - curwin = win; - qf_set_title_var(qf_get_curlist(qi)); - curwin = curwin_save; + FOR_ALL_TAB_WINDOWS(tp, win) { + if (is_qf_win(win, qi)) { + curwin = win; + qf_set_title_var(qfl); + } } + curwin = save_curwin; } // Find the quickfix buffer. If it exists, update the contents. diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index 2878e73573..a2589ac431 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -3605,19 +3605,21 @@ theend: if (backpos.ga_maxlen > BACKPOS_INITIAL) ga_clear(&backpos); - // Make sure the end is never before the start. Can happen when \zs and - // \ze are used. - if (REG_MULTI) { - const lpos_T *const start = &rex.reg_mmatch->startpos[0]; - const lpos_T *const end = &rex.reg_mmatch->endpos[0]; + if (retval > 0) { + // Make sure the end is never before the start. Can happen when \zs + // and \ze are used. + if (REG_MULTI) { + const lpos_T *const start = &rex.reg_mmatch->startpos[0]; + const lpos_T *const end = &rex.reg_mmatch->endpos[0]; - if (end->lnum < start->lnum - || (end->lnum == start->lnum && end->col < start->col)) { - rex.reg_mmatch->endpos[0] = rex.reg_mmatch->startpos[0]; - } - } else { - if (rex.reg_match->endp[0] < rex.reg_match->startp[0]) { - rex.reg_match->endp[0] = rex.reg_match->startp[0]; + if (end->lnum < start->lnum + || (end->lnum == start->lnum && end->col < start->col)) { + rex.reg_mmatch->endpos[0] = rex.reg_mmatch->startpos[0]; + } + } else { + if (rex.reg_match->endp[0] < rex.reg_match->startp[0]) { + rex.reg_match->endp[0] = rex.reg_match->startp[0]; + } } } @@ -3722,8 +3724,7 @@ static long regtry(bt_regprog_T *prog, } else { if (reg_startzp[i] != NULL && reg_endzp[i] != NULL) re_extmatch_out->matches[i] = - vim_strnsave(reg_startzp[i], - (int)(reg_endzp[i] - reg_startzp[i])); + vim_strnsave(reg_startzp[i], reg_endzp[i] - reg_startzp[i]); } } } @@ -6563,7 +6564,7 @@ static int fill_submatch_list(int argc FUNC_ATTR_UNUSED, typval_T *argv, if (s == NULL || rsm.sm_match->endp[i] == NULL) { s = NULL; } else { - s = vim_strnsave(s, (int)(rsm.sm_match->endp[i] - s)); + s = vim_strnsave(s, rsm.sm_match->endp[i] - s); } TV_LIST_ITEM_TV(li)->v_type = VAR_STRING; TV_LIST_ITEM_TV(li)->vval.v_string = s; @@ -7082,7 +7083,7 @@ char_u *reg_submatch(int no) if (s == NULL || rsm.sm_match->endp[no] == NULL) { retval = NULL; } else { - retval = vim_strnsave(s, (int)(rsm.sm_match->endp[no] - s)); + retval = vim_strnsave(s, rsm.sm_match->endp[no] - s); } } diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index 137b2304c0..8b5ee59d40 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -5243,9 +5243,12 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, switch (t->state->c) { case NFA_MATCH: { - // If the match ends before a composing characters and - // rex.reg_icombine is not set, that is not really a match. - if (!rex.reg_icombine && utf_iscomposing(curc)) { + // If the match is not at the start of the line, ends before a + // composing characters and rex.reg_icombine is not set, that + // is not really a match. + if (!rex.reg_icombine + && rex.input != rex.line + && utf_iscomposing(curc)) { break; } nfa_match = true; @@ -6477,8 +6480,7 @@ static long nfa_regtry(nfa_regprog_T *prog, if (lpos->start != NULL && lpos->end != NULL) re_extmatch_out->matches[i] = - vim_strnsave(lpos->start, - (int)(lpos->end - lpos->start)); + vim_strnsave(lpos->start, lpos->end - lpos->start); } } } @@ -6591,19 +6593,21 @@ static long nfa_regexec_both(char_u *line, colnr_T startcol, #endif theend: - // Make sure the end is never before the start. Can happen when \zs and - // \ze are used. - if (REG_MULTI) { - const lpos_T *const start = &rex.reg_mmatch->startpos[0]; - const lpos_T *const end = &rex.reg_mmatch->endpos[0]; + if (retval > 0) { + // Make sure the end is never before the start. Can happen when \zs and + // \ze are used. + if (REG_MULTI) { + const lpos_T *const start = &rex.reg_mmatch->startpos[0]; + const lpos_T *const end = &rex.reg_mmatch->endpos[0]; - if (end->lnum < start->lnum - || (end->lnum == start->lnum && end->col < start->col)) { - rex.reg_mmatch->endpos[0] = rex.reg_mmatch->startpos[0]; - } - } else { - if (rex.reg_match->endp[0] < rex.reg_match->startp[0]) { - rex.reg_match->endp[0] = rex.reg_match->startp[0]; + if (end->lnum < start->lnum + || (end->lnum == start->lnum && end->col < start->col)) { + rex.reg_mmatch->endpos[0] = rex.reg_mmatch->startpos[0]; + } + } else { + if (rex.reg_match->endp[0] < rex.reg_match->startp[0]) { + rex.reg_match->endp[0] = rex.reg_match->startp[0]; + } } } diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 2eeeebb88d..dc028f0ed7 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -620,7 +620,7 @@ int update_screen(int type) /* Clear or redraw the command line. Done last, because scrolling may * mess up the command line. */ - if (clear_cmdline || redraw_cmdline) { + if (clear_cmdline || redraw_cmdline || redraw_mode) { showmode(); } @@ -683,7 +683,7 @@ void conceal_check_cursor_line(void) redrawWinline(curwin, curwin->w_cursor.lnum); // Need to recompute cursor column, e.g., when starting Visual mode // without concealing. */ - curs_columns(true); + curs_columns(curwin, true); } } @@ -1698,7 +1698,7 @@ static void win_update(win_T *wp, Providers *providers) const int new_wcol = wp->w_wcol; recursive = true; curwin->w_valid &= ~VALID_TOPLINE; - update_topline(); // may invalidate w_botline again + update_topline(curwin); // may invalidate w_botline again if (old_wcol != new_wcol && (wp->w_valid & (VALID_WCOL|VALID_WROW)) @@ -2013,6 +2013,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, // end-of-line int lcs_eol_one = wp->w_p_lcs_chars.eol; // 'eol' until it's been used int lcs_prec_todo = wp->w_p_lcs_chars.prec; // 'prec' until it's been used + bool has_fold = foldinfo.fi_level != 0 && foldinfo.fi_lines >= 0; // saved "extra" items for when draw_state becomes WL_LINE (again) int saved_n_extra = 0; @@ -2196,7 +2197,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, } if (wp->w_p_spell - && foldinfo.fi_lines == 0 + && !has_fold && *wp->w_s->b_p_spl != NUL && !GA_EMPTY(&wp->w_s->b_langp) && *(char **)(wp->w_s->b_langp.ga_data) != NULL) { @@ -2299,6 +2300,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, // handle 'incsearch' and ":s///c" highlighting } else if (highlight_match && wp == curwin + && !has_fold && lnum >= curwin->w_cursor.lnum && lnum <= curwin->w_cursor.lnum + search_match_lines) { if (lnum == curwin->w_cursor.lnum) { @@ -2551,7 +2553,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, cur = wp->w_match_head; shl_flag = false; while ((cur != NULL || !shl_flag) && !number_only - && foldinfo.fi_lines == 0 + && !has_fold ) { if (!shl_flag) { shl = &search_hl; @@ -3883,8 +3885,8 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, /* check if line ends before left margin */ if (vcol < v + col - win_col_off(wp)) vcol = v + col - win_col_off(wp); - /* Get rid of the boguscols now, we want to draw until the right - * edge for 'cursorcolumn'. */ + // Get rid of the boguscols now, we want to draw until the right + // edge for 'cursorcolumn'. col -= boguscols; // boguscols = 0; // Disabled because value never read after this @@ -6557,12 +6559,28 @@ void grid_del_lines(ScreenGrid *grid, int row, int line_count, int end, int col, return; } +// Return true when postponing displaying the mode message: when not redrawing +// or inside a mapping. +bool skip_showmode(void) +{ + // Call char_avail() only when we are going to show something, because it + // takes a bit of time. redrawing() may also call char_avail_avail(). + if (global_busy + || msg_silent != 0 + || !redrawing() + || (char_avail() && !KeyTyped)) { + redraw_mode = true; // show mode later + return true; + } + return false; +} // Show the current mode and ruler. // // If clear_cmdline is TRUE, clear the rest of the cmdline. // If clear_cmdline is FALSE there may be a message there that needs to be // cleared only if a mode is shown. +// If redraw_mode is true show or clear the mode. // Return the length of the message (0 if no message). int showmode(void) { @@ -6588,12 +6606,8 @@ int showmode(void) || restart_edit || VIsual_active)); if (do_mode || reg_recording != 0) { - // Don't show mode right now, when not redrawing or inside a mapping. - // Call char_avail() only when we are going to show something, because - // it takes a bit of time. - if (!redrawing() || (char_avail() && !KeyTyped) || msg_silent != 0) { - redraw_cmdline = TRUE; /* show mode later */ - return 0; + if (skip_showmode()) { + return 0; // show mode later } nwr_save = need_wait_return; @@ -6713,10 +6727,11 @@ int showmode(void) need_clear = true; } - mode_displayed = TRUE; - if (need_clear || clear_cmdline) + mode_displayed = true; + if (need_clear || clear_cmdline || redraw_mode) { msg_clr_eos(); - msg_didout = FALSE; /* overwrite this message */ + } + msg_didout = false; // overwrite this message length = msg_col; msg_col = 0; msg_no_more = false; @@ -6725,6 +6740,9 @@ int showmode(void) } else if (clear_cmdline && msg_silent == 0) { // Clear the whole command line. Will reset "clear_cmdline". msg_clr_cmdline(); + } else if (redraw_mode) { + msg_pos_mode(); + msg_clr_eos(); } // NB: also handles clearing the showmode if it was emtpy or disabled @@ -6741,6 +6759,7 @@ int showmode(void) win_redr_ruler(last, true); } redraw_cmdline = false; + redraw_mode = false; clear_cmdline = false; return length; @@ -7380,7 +7399,7 @@ void screen_resize(int width, int height) cmdline_pum_display(false); } } else { - update_topline(); + update_topline(curwin); if (pum_drawn()) { // TODO(bfredl): ins_compl_show_pum wants to redraw the screen first. // For now make sure the nested update_screen(0) won't redraw the diff --git a/src/nvim/sign.c b/src/nvim/sign.c index ffe51287c5..fc9f53c192 100644 --- a/src/nvim/sign.c +++ b/src/nvim/sign.c @@ -173,13 +173,15 @@ static void insert_sign( const char_u *group, // sign group; NULL for global group int prio, // sign priority linenr_T lnum, // line number which gets the mark - int typenr // typenr of sign we are adding + int typenr, // typenr of sign we are adding + bool has_text_or_icon // sign has text or icon ) { signlist_T *newsign = xmalloc(sizeof(signlist_T)); newsign->id = id; newsign->lnum = lnum; newsign->typenr = typenr; + newsign->has_text_or_icon = has_text_or_icon; if (group != NULL) { newsign->group = sign_group_ref(group); } else { @@ -210,13 +212,14 @@ static void insert_sign( /// Insert a new sign sorted by line number and sign priority. static void insert_sign_by_lnum_prio( - buf_T *buf, // buffer to store sign in - signlist_T *prev, // previous sign entry - int id, // sign ID - const char_u *group, // sign group; NULL for global group - int prio, // sign priority - linenr_T lnum, // line number which gets the mark - int typenr // typenr of sign we are adding + buf_T *buf, // buffer to store sign in + signlist_T *prev, // previous sign entry + int id, // sign ID + const char_u *group, // sign group; NULL for global group + int prio, // sign priority + linenr_T lnum, // line number which gets the mark + int typenr, // typenr of sign we are adding + bool has_text_or_icon // sign has text or icon ) { signlist_T *sign; @@ -234,7 +237,7 @@ static void insert_sign_by_lnum_prio( sign = prev->next; } - insert_sign(buf, prev, sign, id, group, prio, lnum, typenr); + insert_sign(buf, prev, sign, id, group, prio, lnum, typenr, has_text_or_icon); } /// Get the name of a sign by its typenr. @@ -342,12 +345,13 @@ static void sign_sort_by_prio_on_line(buf_T *buf, signlist_T *sign) /// Add the sign into the signlist. Find the right spot to do it though. void buf_addsign( - buf_T *buf, // buffer to store sign in - int id, // sign ID + buf_T *buf, // buffer to store sign in + int id, // sign ID const char_u *groupname, // sign group - int prio, // sign priority - linenr_T lnum, // line number which gets the mark - int typenr // typenr of sign we are adding + int prio, // sign priority + linenr_T lnum, // line number which gets the mark + int typenr, // typenr of sign we are adding + bool has_text_or_icon // sign has text or icon ) { signlist_T *sign; // a sign in the signlist @@ -363,13 +367,29 @@ void buf_addsign( sign_sort_by_prio_on_line(buf, sign); return; } else if (lnum < sign->lnum) { - insert_sign_by_lnum_prio(buf, prev, id, groupname, prio, lnum, typenr); + insert_sign_by_lnum_prio( + buf, + prev, + id, + groupname, + prio, + lnum, + typenr, + has_text_or_icon); return; } prev = sign; } - insert_sign_by_lnum_prio(buf, prev, id, groupname, prio, lnum, typenr); + insert_sign_by_lnum_prio( + buf, + prev, + id, + groupname, + prio, + lnum, + typenr, + has_text_or_icon); } // For an existing, placed sign "markId" change the type to "typenr". @@ -786,11 +806,15 @@ static int sign_define_init_text(sign_T *sp, char_u *text) } cells += utf_ptr2cells(s); } - // Currently must be one or two display cells - if (s != endp || cells < 1 || cells > 2) { + // Currently must be empty, one or two display cells + if (s != endp || cells > 2) { EMSG2(_("E239: Invalid sign text: %s"), text); return FAIL; } + if (cells < 1) { + sp->sn_text = NULL; + return OK; + } xfree(sp->sn_text); // Allocate one byte more if we need to pad up @@ -939,7 +963,15 @@ int sign_place( if (lnum > 0) { // ":sign place {id} line={lnum} name={name} file={fname}": // place a sign - buf_addsign(buf, *sign_id, sign_group, prio, lnum, sp->sn_typenr); + bool has_text_or_icon = sp->sn_text != NULL || sp->sn_icon != NULL; + buf_addsign( + buf, + *sign_id, + sign_group, + prio, + lnum, + sp->sn_typenr, + has_text_or_icon); } else { // ":sign place {id} file={fname}": change sign type lnum = buf_change_sign_type(buf, *sign_id, sign_group, sp->sn_typenr); diff --git a/src/nvim/sign_defs.h b/src/nvim/sign_defs.h index 687c15bbd6..c898dba890 100644 --- a/src/nvim/sign_defs.h +++ b/src/nvim/sign_defs.h @@ -1,6 +1,7 @@ #ifndef NVIM_SIGN_DEFS_H #define NVIM_SIGN_DEFS_H +#include <stdbool.h> #include "nvim/pos.h" #include "nvim/types.h" @@ -22,13 +23,14 @@ typedef struct signlist signlist_T; struct signlist { - int id; // unique identifier for each placed sign - linenr_T lnum; // line number which has this sign - int typenr; // typenr of sign - signgroup_T *group; // sign group - int priority; // priority for highlighting - signlist_T *next; // next signlist entry - signlist_T *prev; // previous entry -- for easy reordering + int id; // unique identifier for each placed sign + linenr_T lnum; // line number which has this sign + int typenr; // typenr of sign + bool has_text_or_icon; // has text or icon + signgroup_T *group; // sign group + int priority; // priority for highlighting + signlist_T *next; // next signlist entry + signlist_T *prev; // previous entry -- for easy reordering }; // Default sign priority for highlighting diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c index 90af010164..90945eafd7 100644 --- a/src/nvim/spellfile.c +++ b/src/nvim/spellfile.c @@ -3942,7 +3942,7 @@ static int tree_add_word(spellinfo_T *spin, char_u *word, wordnode_T *root, int msg_start(); msg_puts(_(msg_compressing)); msg_clr_eos(); - msg_didout = FALSE; + msg_didout = false; msg_col = 0; ui_flush(); } diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index e91d560284..4d88df5a3a 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -4186,10 +4186,10 @@ get_syn_options( arg = skiptowhite(arg); if (gname_start == arg) return NULL; - gname = vim_strnsave(gname_start, (int)(arg - gname_start)); - if (STRCMP(gname, "NONE") == 0) + gname = vim_strnsave(gname_start, arg - gname_start); + if (STRCMP(gname, "NONE") == 0) { *opt->sync_idx = NONE_IDX; - else { + } else { syn_id = syn_name2id(gname); int i; for (i = curwin->w_s->b_syn_patterns.ga_len; --i >= 0; ) @@ -4587,7 +4587,7 @@ syn_cmd_region( while (*key_end && !ascii_iswhite(*key_end) && *key_end != '=') ++key_end; xfree(key); - key = vim_strnsave_up(rest, (int)(key_end - rest)); + key = vim_strnsave_up(rest, key_end - rest); if (STRCMP(key, "MATCHGROUP") == 0) { item = ITEM_MATCHGROUP; } else if (STRCMP(key, "START") == 0) { @@ -5047,8 +5047,8 @@ static char_u *get_syn_pattern(char_u *arg, synpat_T *ci) EMSG2(_("E401: Pattern delimiter not found: %s"), arg); return NULL; } - /* store the pattern and compiled regexp program */ - ci->sp_pattern = vim_strnsave(arg + 1, (int)(end - arg - 1)); + // store the pattern and compiled regexp program + ci->sp_pattern = vim_strnsave(arg + 1, end - arg - 1); /* Make 'cpoptions' empty, to avoid the 'l' flag */ cpo_save = p_cpo; @@ -5136,7 +5136,7 @@ static void syn_cmd_sync(exarg_T *eap, int syncing) arg_end = skiptowhite(arg_start); next_arg = skipwhite(arg_end); xfree(key); - key = vim_strnsave_up(arg_start, (int)(arg_end - arg_start)); + key = vim_strnsave_up(arg_start, arg_end - arg_start); if (STRCMP(key, "CCOMMENT") == 0) { if (!eap->skip) curwin->w_s->b_syn_sync_flags |= SF_CCOMMENT; @@ -5195,7 +5195,7 @@ static void syn_cmd_sync(exarg_T *eap, int syncing) if (!eap->skip) { /* store the pattern and compiled regexp program */ curwin->w_s->b_syn_linecont_pat = - vim_strnsave(next_arg + 1, (int)(arg_end - next_arg - 1)); + vim_strnsave(next_arg + 1, arg_end - next_arg - 1); curwin->w_s->b_syn_linecont_ic = curwin->w_s->b_syn_ic; /* Make 'cpoptions' empty, to avoid the 'l' flag */ @@ -5555,18 +5555,17 @@ void ex_syntax(exarg_T *eap) { char_u *arg = eap->arg; char_u *subcmd_end; - char_u *subcmd_name; - int i; syn_cmdlinep = eap->cmdlinep; - /* isolate subcommand name */ - for (subcmd_end = arg; ASCII_ISALPHA(*subcmd_end); ++subcmd_end) - ; - subcmd_name = vim_strnsave(arg, (int)(subcmd_end - arg)); - if (eap->skip) /* skip error messages for all subcommands */ - ++emsg_skip; - for (i = 0;; ++i) { + // isolate subcommand name + for (subcmd_end = arg; ASCII_ISALPHA(*subcmd_end); subcmd_end++) { + } + char_u *const subcmd_name = vim_strnsave(arg, subcmd_end - arg); + if (eap->skip) { // skip error messages for all subcommands + emsg_skip++; + } + for (int i = 0;; i++) { if (subcommands[i].name == NULL) { EMSG2(_("E410: Invalid :syntax subcommand: %s"), subcmd_name); break; @@ -6719,7 +6718,7 @@ void do_highlight(const char *line, const bool forceit, const bool init) } xfree(key); key = (char *)vim_strnsave_up((const char_u *)key_start, - (int)(linep - key_start)); + linep - key_start); linep = (const char *)skipwhite((const char_u *)linep); if (strcmp(key, "NONE") == 0) { diff --git a/src/nvim/testdir/check.vim b/src/nvim/testdir/check.vim index 7f6b7dcfec..24d3959f83 100644 --- a/src/nvim/testdir/check.vim +++ b/src/nvim/testdir/check.vim @@ -12,6 +12,9 @@ endfunc " Command to check for the presence of a working option. command -nargs=1 CheckOption call CheckOption(<f-args>) func CheckOption(name) + if !exists('&' .. a:name) + throw 'Checking for non-existent option ' .. a:name + endif if !exists('+' .. a:name) throw 'Skipped: ' .. a:name .. ' option not supported' endif @@ -74,6 +77,14 @@ func CheckCanRunGui() endif endfunc +" Command to check that we are using the GUI +command CheckGui call CheckGui() +func CheckGui() + if !has('gui_running') + throw 'Skipped: only works in the GUI' + endif +endfunc + " Command to check that not currently using the GUI command CheckNotGui call CheckNotGui() func CheckNotGui() diff --git a/src/nvim/testdir/setup.vim b/src/nvim/testdir/setup.vim index d032c9a739..fd9cfb54be 100644 --- a/src/nvim/testdir/setup.vim +++ b/src/nvim/testdir/setup.vim @@ -20,6 +20,7 @@ set tags=./tags,tags set undodir^=. set wildoptions= set startofline +set sessionoptions&vi " Prevent Nvim log from writing to stderr. let $NVIM_LOG_FILE = exists($NVIM_LOG_FILE) ? $NVIM_LOG_FILE : 'Xnvim.log' diff --git a/src/nvim/testdir/test_bufline.vim b/src/nvim/testdir/test_bufline.vim index 076f03fdd8..2567dd2be2 100644 --- a/src/nvim/testdir/test_bufline.vim +++ b/src/nvim/testdir/test_bufline.vim @@ -19,7 +19,7 @@ func Test_setbufline_getbufline() let b = bufnr('%') wincmd w call assert_equal(1, setbufline(b, 5, ['x'])) - call assert_equal(1, setbufline(1234, 1, ['x'])) + call assert_equal(1, setbufline(bufnr('$') + 1, 1, ['x'])) call assert_equal(0, setbufline(b, 4, ['d', 'e'])) call assert_equal(['c'], getbufline(b, 3)) call assert_equal(['d'], getbufline(b, 4)) diff --git a/src/nvim/testdir/test_clientserver.vim b/src/nvim/testdir/test_clientserver.vim index 3377f86126..53704bd094 100644 --- a/src/nvim/testdir/test_clientserver.vim +++ b/src/nvim/testdir/test_clientserver.vim @@ -61,6 +61,15 @@ func Test_client_server() call assert_fails('call remote_send("XXX", ":let testvar = ''yes''\<CR>")', 'E241') + call writefile(['one'], 'Xclientfile') + let cmd = GetVimProg() .. ' --servername ' .. name .. ' --remote Xclientfile' + call system(cmd) + call WaitForAssert({-> assert_equal('Xclientfile', remote_expr(name, "bufname()", "", 2))}) + call WaitForAssert({-> assert_equal('one', remote_expr(name, "getline(1)", "", 2))}) + call writefile(['one', 'two'], 'Xclientfile') + call system(cmd) + call WaitForAssert({-> assert_equal('two', remote_expr(name, "getline(2)", "", 2))}) + " Expression evaluated locally. if v:servername == '' call remote_startserver('MYSELF') diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index 81f653c393..39f865144a 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -51,6 +51,22 @@ func Test_complete_wildmenu() call feedkeys(":e Xdir1/\<Tab>\<Down>\<Up>\<Right>\<CR>", 'tx') call assert_equal('testfile1', getline(1)) + " this fails in some Unix GUIs, not sure why + if !has('unix') || !has('gui_running') + " <C-J>/<C-K> mappings to go up/down directories when 'wildcharm' is + " different than 'wildchar'. + set wildcharm=<C-Z> + cnoremap <C-J> <Down><C-Z> + cnoremap <C-K> <Up><C-Z> + call feedkeys(":e Xdir1/\<Tab>\<C-J>\<CR>", 'tx') + call assert_equal('testfile3', getline(1)) + call feedkeys(":e Xdir1/\<Tab>\<C-J>\<C-K>\<CR>", 'tx') + call assert_equal('testfile1', getline(1)) + set wildcharm=0 + cunmap <C-J> + cunmap <C-K> + endif + " cleanup %bwipe call delete('Xdir1/Xdir2/Xtestfile4') @@ -62,6 +78,33 @@ func Test_complete_wildmenu() set nowildmenu endfunc +func Test_wildmenu_screendump() + CheckScreendump + + let lines =<< trim [SCRIPT] + set wildmenu hlsearch + [SCRIPT] + call writefile(lines, 'XTest_wildmenu') + + let buf = RunVimInTerminal('-S XTest_wildmenu', {'rows': 8}) + call term_sendkeys(buf, ":vim\<Tab>") + call VerifyScreenDump(buf, 'Test_wildmenu_1', {}) + + call term_sendkeys(buf, "\<Tab>") + call VerifyScreenDump(buf, 'Test_wildmenu_2', {}) + + call term_sendkeys(buf, "\<Tab>") + call VerifyScreenDump(buf, 'Test_wildmenu_3', {}) + + call term_sendkeys(buf, "\<Tab>") + call VerifyScreenDump(buf, 'Test_wildmenu_4', {}) + call term_sendkeys(buf, "\<Esc>") + + " clean up + call StopVimInTerminal(buf) + call delete('XTest_wildmenu') +endfunc + func Test_map_completion() if !has('cmdline_compl') return @@ -548,6 +591,13 @@ func Test_cmdline_complete_user_names() endif endfunc +func Test_cmdline_complete_bang() + if executable('whoami') + call feedkeys(":!whoam\<C-A>\<C-B>\"\<CR>", 'tx') + call assert_match('^".*\<whoami\>', @:) + endif +endfunc + funct Test_cmdline_complete_languages() let lang = substitute(execute('language messages'), '.*"\(.*\)"$', '\1', '') @@ -570,6 +620,17 @@ funct Test_cmdline_complete_languages() endif endfunc +func Test_cmdline_complete_expression() + let g:SomeVar = 'blah' + for cmd in ['exe', 'echo', 'echon', 'echomsg'] + call feedkeys(":" .. cmd .. " SomeV\<Tab>\<C-B>\"\<CR>", 'tx') + call assert_match('"' .. cmd .. ' SomeVar', @:) + call feedkeys(":" .. cmd .. " foo SomeV\<Tab>\<C-B>\"\<CR>", 'tx') + call assert_match('"' .. cmd .. ' foo SomeVar', @:) + endfor + unlet g:SomeVar +endfunc + func Test_cmdline_write_alternatefile() new call setline('.', ['one', 'two']) @@ -819,6 +880,36 @@ func Test_cmdwin_cedit() delfunc CmdWinType endfunc +func Test_cmdwin_restore() + CheckScreendump + + let lines =<< trim [SCRIPT] + call setline(1, range(30)) + 2split + [SCRIPT] + call writefile(lines, 'XTest_restore') + + let buf = RunVimInTerminal('-S XTest_restore', {'rows': 12}) + call term_wait(buf, 100) + call term_sendkeys(buf, "q:") + call VerifyScreenDump(buf, 'Test_cmdwin_restore_1', {}) + + " normal restore + call term_sendkeys(buf, ":q\<CR>") + call VerifyScreenDump(buf, 'Test_cmdwin_restore_2', {}) + + " restore after setting 'lines' with one window + call term_sendkeys(buf, ":close\<CR>") + call term_sendkeys(buf, "q:") + call term_sendkeys(buf, ":set lines=18\<CR>") + call term_sendkeys(buf, ":q\<CR>") + call VerifyScreenDump(buf, 'Test_cmdwin_restore_3', {}) + + " clean up + call StopVimInTerminal(buf) + call delete('XTest_restore') +endfunc + func Test_buffers_lastused() " check that buffers are sorted by time when wildmode has lastused edit bufc " oldest @@ -894,5 +985,23 @@ func Test_zero_line_search() q! endfunc +func Test_read_shellcmd() + CheckUnix + if executable('ls') + " There should be ls in the $PATH + call feedkeys(":r! l\<c-a>\<c-b>\"\<cr>", 'tx') + call assert_match('^"r! .*\<ls\>', @:) + endif + + if executable('rm') + call feedkeys(":r! ++enc=utf-8 r\<c-a>\<c-b>\"\<cr>", 'tx') + call assert_notmatch('^"r!.*\<runtest.vim\>', @:) + call assert_match('^"r!.*\<rm\>', @:) + + call feedkeys(":r ++enc=utf-8 !rm\<c-a>\<c-b>\"\<cr>", 'tx') + call assert_notmatch('^"r.*\<runtest.vim\>', @:) + call assert_match('^"r ++enc\S\+ !.*\<rm\>', @:) + endif +endfunc -" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab +" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_digraph.vim b/src/nvim/testdir/test_digraph.vim index 9eea27740d..b6d9687560 100644 --- a/src/nvim/testdir/test_digraph.vim +++ b/src/nvim/testdir/test_digraph.vim @@ -1,8 +1,8 @@ " Tests for digraphs -if !has("digraphs") - finish -endif +source check.vim +CheckFeature digraphs +source term_util.vim func Put_Dig(chars) exe "norm! o\<c-k>".a:chars @@ -487,4 +487,20 @@ func Test_show_digraph_cp1251() bwipe! endfunc +" Test for the characters displayed on the screen when entering a digraph +func Test_entering_digraph() + CheckRunVimInTerminal + let buf = RunVimInTerminal('', {'rows': 6}) + call term_sendkeys(buf, "i\<C-K>") + call term_wait(buf) + call assert_equal('?', term_getline(buf, 1)) + call term_sendkeys(buf, "1") + call term_wait(buf) + call assert_equal('1', term_getline(buf, 1)) + call term_sendkeys(buf, "2") + call term_wait(buf) + call assert_equal('½', term_getline(buf, 1)) + call StopVimInTerminal(buf) +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_fileformat.vim b/src/nvim/testdir/test_fileformat.vim index 8dc25f62b1..465613f1cf 100644 --- a/src/nvim/testdir/test_fileformat.vim +++ b/src/nvim/testdir/test_fileformat.vim @@ -31,3 +31,26 @@ func Test_fileformat_autocommand() au! BufReadPre Xfile bw! endfunc + +" Test for changing the fileformat using ++read +func Test_fileformat_plusplus_read() + new + call setline(1, ['one', 'two', 'three']) + w ++ff=dos Xfile1 + enew! + set ff=unix + " A :read doesn't change the fileformat, but does apply to the read lines. + r ++fileformat=unix Xfile1 + call assert_equal('unix', &fileformat) + call assert_equal("three\r", getline('$')) + 3r ++edit Xfile1 + call assert_equal('dos', &fileformat) + close! + call delete('Xfile1') + set fileformat& + call assert_fails('e ++fileformat Xfile1', 'E474:') + call assert_fails('e ++ff=abc Xfile1', 'E474:') + call assert_fails('e ++abc1 Xfile1', 'E474:') +endfunc + +" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim index 356a7ce135..2123780f11 100644 --- a/src/nvim/testdir/test_filetype.vim +++ b/src/nvim/testdir/test_filetype.vim @@ -181,6 +181,7 @@ let s:filename_checks = { \ 'gdb': ['.gdbinit'], \ 'gdmo': ['file.mo', 'file.gdmo'], \ 'gedcom': ['file.ged', 'lltxxxxx.txt'], + \ 'gift': ['file.gift'], \ 'gitcommit': ['COMMIT_EDITMSG', 'MERGE_MSG', 'TAG_EDITMSG'], \ 'gitconfig': ['file.git/config', '.gitconfig', '.gitmodules', 'file.git/modules//config', '/.config/git/config', '/etc/gitconfig'], \ 'gitolite': ['gitolite.conf'], diff --git a/src/nvim/testdir/test_fold.vim b/src/nvim/testdir/test_fold.vim index 3c90c45952..88ce64b9eb 100644 --- a/src/nvim/testdir/test_fold.vim +++ b/src/nvim/testdir/test_fold.vim @@ -815,4 +815,11 @@ func Test_fold_create_delete_create() bwipe! endfunc +" this was crashing +func Test_fold_create_delete() + new + norm zFzFzdzj + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_global.vim b/src/nvim/testdir/test_global.vim index bdeaf8e2cf..7ccf2812ff 100644 --- a/src/nvim/testdir/test_global.vim +++ b/src/nvim/testdir/test_global.vim @@ -1,3 +1,4 @@ +source check.vim func Test_yank_put_clipboard() new @@ -10,6 +11,16 @@ func Test_yank_put_clipboard() bwipe! endfunc +func Test_global_set_clipboard() + CheckFeature clipboard_working + new + set clipboard=unnamedplus + let @+='clipboard' | g/^/set cb= | let @" = 'unnamed' | put + call assert_equal(['','unnamed'], getline(1, '$')) + set clipboard& + bwipe! +endfunc + func Test_nested_global() new call setline(1, ['nothing', 'found', 'found bad', 'bad']) diff --git a/src/nvim/testdir/test_help.vim b/src/nvim/testdir/test_help.vim index 01fb9917e9..8e59efd22d 100644 --- a/src/nvim/testdir/test_help.vim +++ b/src/nvim/testdir/test_help.vim @@ -56,3 +56,49 @@ func Test_help_local_additions() call delete('Xruntime', 'rf') let &rtp = rtp_save endfunc + +" Test for the :helptags command +func Test_helptag_cmd() + call mkdir('Xdir/a/doc', 'p') + + " No help file to process in the directory + call assert_fails('helptags Xdir', 'E151:') + + call writefile([], 'Xdir/a/doc/sample.txt') + + " Test for ++t argument + helptags ++t Xdir + call assert_equal(["help-tags\ttags\t1"], readfile('Xdir/tags')) + call delete('Xdir/tags') + + " The following tests fail on FreeBSD for some reason + if has('unix') && !has('bsd') + " Read-only tags file + call mkdir('Xdir/doc', 'p') + call writefile([''], 'Xdir/doc/tags') + call writefile([], 'Xdir/doc/sample.txt') + call setfperm('Xdir/doc/tags', 'r-xr--r--') + call assert_fails('helptags Xdir/doc', 'E152:', getfperm('Xdir/doc/tags')) + + let rtp = &rtp + let &rtp = 'Xdir' + helptags ALL + let &rtp = rtp + + call delete('Xdir/doc/tags') + + " No permission to read the help file + call setfperm('Xdir/a/doc/sample.txt', '-w-------') + call assert_fails('helptags Xdir', 'E153:', getfperm('Xdir/a/doc/sample.txt')) + call delete('Xdir/a/doc/sample.txt') + call delete('Xdir/tags') + endif + + " Duplicate tags in the help file + call writefile(['*tag1*', '*tag1*', '*tag2*'], 'Xdir/a/doc/sample.txt') + call assert_fails('helptags Xdir', 'E154:') + + call delete('Xdir', 'rf') +endfunc + +" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_messages.vim b/src/nvim/testdir/test_messages.vim index 30239a90c2..d0a8f342c9 100644 --- a/src/nvim/testdir/test_messages.vim +++ b/src/nvim/testdir/test_messages.vim @@ -89,6 +89,65 @@ func Test_echoerr() call test_ignore_error('RESET') endfunc +func Test_mode_message_at_leaving_insert_by_ctrl_c() + if !has('terminal') || has('gui_running') + return + endif + + " Set custom statusline built by user-defined function. + let testfile = 'Xtest.vim' + call writefile([ + \ 'func StatusLine() abort', + \ ' return ""', + \ 'endfunc', + \ 'set statusline=%!StatusLine()', + \ 'set laststatus=2', + \ ], testfile) + + let rows = 10 + let buf = term_start([GetVimProg(), '--clean', '-S', testfile], {'term_rows': rows}) + call term_wait(buf, 200) + call assert_equal('run', job_status(term_getjob(buf))) + + call term_sendkeys(buf, "i") + call WaitForAssert({-> assert_match('^-- INSERT --\s*$', term_getline(buf, rows))}) + call term_sendkeys(buf, "\<C-C>") + call WaitForAssert({-> assert_match('^\s*$', term_getline(buf, rows))}) + + call term_sendkeys(buf, ":qall!\<CR>") + call WaitForAssert({-> assert_equal('dead', job_status(term_getjob(buf)))}) + exe buf . 'bwipe!' + call delete(testfile) +endfunc + +func Test_mode_message_at_leaving_insert_with_esc_mapped() + if !has('terminal') || has('gui_running') + return + endif + + " Set custom statusline built by user-defined function. + let testfile = 'Xtest.vim' + call writefile([ + \ 'set laststatus=2', + \ 'inoremap <Esc> <Esc>00', + \ ], testfile) + + let rows = 10 + let buf = term_start([GetVimProg(), '--clean', '-S', testfile], {'term_rows': rows}) + call term_wait(buf, 200) + call assert_equal('run', job_status(term_getjob(buf))) + + call term_sendkeys(buf, "i") + call WaitForAssert({-> assert_match('^-- INSERT --\s*$', term_getline(buf, rows))}) + call term_sendkeys(buf, "\<Esc>") + call WaitForAssert({-> assert_match('^\s*$', term_getline(buf, rows))}) + + call term_sendkeys(buf, ":qall!\<CR>") + call WaitForAssert({-> assert_equal('dead', job_status(term_getjob(buf)))}) + exe buf . 'bwipe!' + call delete(testfile) +endfunc + func Test_echospace() set noruler noshowcmd laststatus=1 call assert_equal(&columns - 1, v:echospace) diff --git a/src/nvim/testdir/test_mksession.vim b/src/nvim/testdir/test_mksession.vim index 215065f941..8ef8bbc23a 100644 --- a/src/nvim/testdir/test_mksession.vim +++ b/src/nvim/testdir/test_mksession.vim @@ -128,6 +128,7 @@ func Test_mksession() call delete('Xtest_mks.out') call delete(tmpfile) let &wrap = wrap_save + set sessionoptions& endfunc func Test_mksession_winheight() @@ -154,7 +155,7 @@ func Test_mksession_rtp() return endif new - set sessionoptions+=options + set sessionoptions&vi let _rtp=&rtp " Make a real long (invalid) runtimepath value, " that should exceed PATH_MAX (hopefully) @@ -174,6 +175,7 @@ func Test_mksession_rtp() call assert_equal(expected, li) call delete('Xtest_mks.out') + set sessionoptions& endfunc " Verify that arglist is stored correctly to the session file. @@ -218,6 +220,25 @@ func Test_mksession_one_buffer_two_windows() call delete('Xtest_mks.out') endfunc +if has('extra_search') + +func Test_mksession_hlsearch() + set sessionoptions&vi + set hlsearch + mksession! Xtest_mks.out + nohlsearch + source Xtest_mks.out + call assert_equal(1, v:hlsearch, 'session should restore search highlighting state') + nohlsearch + mksession! Xtest_mks.out + source Xtest_mks.out + call assert_equal(0, v:hlsearch, 'session should restore search highlighting state') + set sessionoptions& + call delete('Xtest_mks.out') +endfunc + +endif + " Test :mkview with a file argument. func Test_mkview_file() " Create a view with line number and a fold. diff --git a/src/nvim/testdir/test_normal.vim b/src/nvim/testdir/test_normal.vim index ad6d325510..7a846e5ea0 100644 --- a/src/nvim/testdir/test_normal.vim +++ b/src/nvim/testdir/test_normal.vim @@ -222,6 +222,21 @@ func Test_normal05_formatexpr_setopt() set formatexpr= endfunc +" When 'formatexpr' returns non-zero, internal formatting is used. +func Test_normal_formatexpr_returns_nonzero() + new + call setline(1, ['one', 'two']) + func! Format() + return 1 + endfunc + setlocal formatexpr=Format() + normal VGgq + call assert_equal(['one two'], getline(1, '$')) + setlocal formatexpr= + delfunc Format + close! +endfunc + func Test_normal06_formatprg() " basic test for formatprg " only test on non windows platform diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index 5323b1acf3..563dbd90d9 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -3762,6 +3762,30 @@ func Test_qftitle() call setqflist([], 'r', {'items' : [{'filename' : 'a.c', 'lnum' : 10}]}) call assert_equal('Errors', w:quickfix_title) cclose + + " Switching to another quickfix list in one tab page should update the + " quickfix window title and statusline in all the other tab pages also + call setqflist([], 'f') + %bw! + cgetexpr ['file_one:1:1: error in the first quickfix list'] + call setqflist([], 'a', {'title': 'first quickfix list'}) + cgetexpr ['file_two:2:1: error in the second quickfix list'] + call setqflist([], 'a', {'title': 'second quickfix list'}) + copen + wincmd t + tabnew two + copen + wincmd t + colder + call assert_equal('first quickfix list', gettabwinvar(1, 2, 'quickfix_title')) + call assert_equal('first quickfix list', gettabwinvar(2, 2, 'quickfix_title')) + call assert_equal(1, tabpagewinnr(1)) + call assert_equal(1, tabpagewinnr(2)) + tabnew + call setqflist([], 'a', {'title': 'new quickfix title'}) + call assert_equal('new quickfix title', gettabwinvar(1, 2, 'quickfix_title')) + call assert_equal('new quickfix title', gettabwinvar(2, 2, 'quickfix_title')) + %bw! endfunc func Test_lbuffer_with_bwipe() diff --git a/src/nvim/testdir/test_regexp_utf8.vim b/src/nvim/testdir/test_regexp_utf8.vim index 4466ad436a..513780938e 100644 --- a/src/nvim/testdir/test_regexp_utf8.vim +++ b/src/nvim/testdir/test_regexp_utf8.vim @@ -533,4 +533,15 @@ func Test_search_with_end_offset() close! endfunc +" Check that "^" matches even when the line starts with a combining char +func Test_match_start_of_line_combining() + new + call setline(1, ['', "\u05ae", '']) + exe "normal gg/^\<CR>" + call assert_equal(2, getcurpos()[1]) + bwipe! +endfunc + + + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_registers.vim b/src/nvim/testdir/test_registers.vim index 19a7c6c9d0..8d2a768ba0 100644 --- a/src/nvim/testdir/test_registers.vim +++ b/src/nvim/testdir/test_registers.vim @@ -2,6 +2,9 @@ " Tests for register operations " +source check.vim +source view_util.vim + " This test must be executed first to check for empty and unset registers. func Test_aaa_empty_reg_test() call assert_fails('normal @@', 'E748:') @@ -52,31 +55,44 @@ func Test_display_registers() let b = execute('registers') call assert_equal(a, b) - call assert_match('^\n--- Registers ---\n' - \ . '"" a\n' - \ . '"0 ba\n' - \ . '"1 b\n' - \ . '"a b\n' + call assert_match('^\nType Name Content\n' + \ . ' c "" a\n' + \ . ' c "0 ba\n' + \ . ' c "1 b\n' + \ . ' c "a b\n' \ . '.*' - \ . '"- a\n' + \ . ' c "- a\n' \ . '.*' - \ . '": ls\n' - \ . '"% file2\n' - \ . '"# file1\n' - \ . '"/ bar\n' - \ . '"= 2\*4', a) + \ . ' c ": ls\n' + \ . ' c "% file2\n' + \ . ' c "# file1\n' + \ . ' c "/ bar\n' + \ . ' c "= 2\*4', a) let a = execute('registers a') - call assert_match('^\n--- Registers ---\n' - \ . '"a b', a) + call assert_match('^\nType Name Content\n' + \ . ' c "a b', a) let a = execute('registers :') - call assert_match('^\n--- Registers ---\n' - \ . '": ls', a) + call assert_match('^\nType Name Content\n' + \ . ' c ": ls', a) bwipe! endfunc +func Test_recording_status_in_ex_line() + norm qx + redraw! + call assert_equal('recording @x', Screenline(&lines)) + set shortmess=q + redraw! + call assert_equal('recording', Screenline(&lines)) + set shortmess& + norm q + redraw! + call assert_equal('', Screenline(&lines)) +endfunc + " Check that replaying a typed sequence does not use an Esc and following " characters as an escape sequence. func Test_recording_esc_sequence() @@ -254,4 +270,15 @@ func Test_ve_blockpaste() bwipe! endfunc +func Test_insert_small_delete() + new + call setline(1, ['foo foobar bar']) + call cursor(1,1) + exe ":norm! ciw'\<C-R>-'" + call assert_equal("'foo' foobar bar", getline(1)) + exe ":norm! w.w." + call assert_equal("'foo' 'foobar' 'bar'", getline(1)) + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_signals.vim b/src/nvim/testdir/test_signals.vim new file mode 100644 index 0000000000..338c0d79ff --- /dev/null +++ b/src/nvim/testdir/test_signals.vim @@ -0,0 +1,140 @@ +" Test signal handling. + +source check.vim +source term_util.vim + +CheckUnix + +source shared.vim + +" Check whether a signal is available on this system. +func HasSignal(signal) + let signals = system('kill -l') + return signals =~# '\<' .. a:signal .. '\>' +endfunc + +" Test signal WINCH (window resize signal) +func Test_signal_WINCH() + throw 'skipped: Nvim cannot avoid terminal resize' + if has('gui_running') || !HasSignal('WINCH') + return + endif + + " We do not actually want to change the size of the terminal. + let old_WS = '' + if exists('&t_WS') + let old_WS = &t_WS + let &t_WS = '' + endif + + let old_lines = &lines + let old_columns = &columns + let new_lines = &lines - 2 + let new_columns = &columns - 2 + + exe 'set lines=' .. new_lines + exe 'set columns=' .. new_columns + call assert_equal(new_lines, &lines) + call assert_equal(new_columns, &columns) + + " Send signal and wait for signal to be processed. + " 'lines' and 'columns' should have been restored + " after handing signal WINCH. + exe 'silent !kill -s WINCH ' .. getpid() + call WaitForAssert({-> assert_equal(old_lines, &lines)}) + call assert_equal(old_columns, &columns) + + if old_WS != '' + let &t_WS = old_WS + endif +endfunc + +" Test signal PWR, which should update the swap file. +func Test_signal_PWR() + if !HasSignal('PWR') + return + endif + + " Set a very large 'updatetime' and 'updatecount', so that we can be sure + " that swap file is updated as a result of sending PWR signal, and not + " because of exceeding 'updatetime' or 'updatecount' when changing buffer. + set updatetime=100000 updatecount=100000 + new Xtest_signal_PWR + let swap_name = swapname('%') + call setline(1, '123') + preserve + let swap_content = readfile(swap_name, 'b') + + " Update the buffer and check that the swap file is not yet updated, + " since we set 'updatetime' and 'updatecount' to large values. + call setline(1, 'abc') + call assert_equal(swap_content, readfile(swap_name, 'b')) + + " Sending PWR signal should update the swap file. + exe 'silent !kill -s PWR ' .. getpid() + call WaitForAssert({-> assert_notequal(swap_content, readfile(swap_name, 'b'))}) + + bwipe! + set updatetime& updatecount& +endfunc + +" Test a deadly signal. +" +" There are several deadly signals: SISEGV, SIBUS, SIGTERM... +" Test uses signal SIGTERM as it does not create a core +" dump file unlike SIGSEGV, SIGBUS, etc. See "man 7 signals. +" +" Vim should exit with a deadly signal and unsaved changes +" should be recoverable from the swap file preserved as a +" result of the deadly signal handler. +func Test_deadly_signal_TERM() + if !HasSignal('TERM') + throw 'Skipped: TERM signal not supported' + endif + if !CanRunVimInTerminal() + throw 'Skipped: cannot run vim in terminal' + endif + let cmd = GetVimCommand() + if cmd =~ 'valgrind' + throw 'Skipped: cannot test signal TERM with valgrind' + endif + + " If test fails once, it can leave temporary files and trying to rerun + " the test would then fail again if they are not deleted first. + call delete('.Xsig_TERM.swp') + call delete('XsetupAucmd') + call delete('XautoOut') + let lines =<< trim END + au VimLeave * call writefile(["VimLeave triggered"], "XautoOut", "as") + au VimLeavePre * call writefile(["VimLeavePre triggered"], "XautoOut", "as") + END + call writefile(lines, 'XsetupAucmd') + + let buf = RunVimInTerminal('-S XsetupAucmd Xsig_TERM', {'rows': 6}) + let pid_vim = term_getjob(buf)->job_info().process + + call term_sendkeys(buf, ":call setline(1, 'foo')\n") + call WaitForAssert({-> assert_equal('foo', term_getline(buf, 1))}) + + call assert_false(filereadable('Xsig_TERM')) + exe 'silent !kill -s TERM ' .. pid_vim + call WaitForAssert({-> assert_true(filereadable('.Xsig_TERM.swp'))}) + + " Don't call StopVimInTerminal() as it expects job to be still running. + call WaitForAssert({-> assert_equal("finished", term_getstatus(buf))}) + + new + silent recover .Xsig_TERM.swp + call assert_equal(['foo'], getline(1, '$')) + + let result = readfile('XautoOut') + call assert_match('VimLeavePre triggered', result[0]) + call assert_match('VimLeave triggered', result[1]) + + %bwipe! + call delete('.Xsig_TERM.swp') + call delete('XsetupAucmd') + call delete('XautoOut') +endfunc + +" vim: ts=8 sw=2 sts=2 tw=80 fdm=marker diff --git a/src/nvim/testdir/test_signs.vim b/src/nvim/testdir/test_signs.vim index 1e6c311374..4bbd722fdb 100644 --- a/src/nvim/testdir/test_signs.vim +++ b/src/nvim/testdir/test_signs.vim @@ -122,9 +122,9 @@ func Test_sign() call assert_fails("sign define Sign4 text=a\e linehl=Comment", 'E239:') call assert_fails("sign define Sign4 text=\ea linehl=Comment", 'E239:') - " Only 1 or 2 character text is allowed + " Only 0, 1 or 2 character text is allowed call assert_fails("sign define Sign4 text=abc linehl=Comment", 'E239:') - call assert_fails("sign define Sign4 text= linehl=Comment", 'E239:') + " call assert_fails("sign define Sign4 text= linehl=Comment", 'E239:') call assert_fails("sign define Sign4 text=\\ ab linehl=Comment", 'E239:') " define sign with whitespace @@ -306,7 +306,7 @@ func Test_sign_invalid_commands() call assert_fails('sign jump 1 name=', 'E474:') call assert_fails('sign jump 1 name=Sign1', 'E474:') call assert_fails('sign jump 1 line=100', '474:') - call assert_fails('sign define Sign2 text=', 'E239:') + " call assert_fails('sign define Sign2 text=', 'E239:') " Non-numeric identifier for :sign place call assert_fails("sign place abc line=3 name=Sign1 buffer=" . bufnr(''), \ 'E474:') @@ -415,7 +415,7 @@ func Test_sign_funcs() " Tests for invalid arguments to sign_define() call assert_fails('call sign_define("sign4", {"text" : "===>"})', 'E239:') - call assert_fails('call sign_define("sign5", {"text" : ""})', 'E239:') + " call assert_fails('call sign_define("sign5", {"text" : ""})', 'E239:') call assert_fails('call sign_define([])', 'E730:') call assert_fails('call sign_define("sign6", [])', 'E715:') diff --git a/src/nvim/testdir/test_startup.vim b/src/nvim/testdir/test_startup.vim index 6214975ef5..e7f332bc4c 100644 --- a/src/nvim/testdir/test_startup.vim +++ b/src/nvim/testdir/test_startup.vim @@ -686,3 +686,53 @@ func Test_v_argv() call assert_true(idx > 2) call assert_equal(['arg1', '--cmd', 'echo v:argv', '--cmd', 'q'']'], list[idx:]) endfunc + +" Test the '-T' argument which sets the 'term' option. +func Test_T_arg() + throw 'skipped: Nvim does not support "-T" argument' + CheckNotGui + let after =<< trim [CODE] + call writefile([&term], "Xtest_T_arg") + qall + [CODE] + + for t in ['builtin_dumb', 'builtin_ansi'] + if RunVim([], after, '-T ' .. t) + let lines = readfile('Xtest_T_arg') + call assert_equal([t], lines) + endif + endfor + + call delete('Xtest_T_arg') +endfunc + +" Test the '-x' argument to read/write encrypted files. +func Test_x_arg() + CheckRunVimInTerminal + CheckFeature cryptv + + " Create an encrypted file Xtest_x_arg. + let buf = RunVimInTerminal('-n -x Xtest_x_arg', #{rows: 10, wait_for_ruler: 0}) + call WaitForAssert({-> assert_match('^Enter encryption key: ', term_getline(buf, 10))}) + call term_sendkeys(buf, "foo\n") + call WaitForAssert({-> assert_match('^Enter same key again: ', term_getline(buf, 10))}) + call term_sendkeys(buf, "foo\n") + call WaitForAssert({-> assert_match(' All$', term_getline(buf, 10))}) + call term_sendkeys(buf, "itest\<Esc>:w\<Enter>") + call WaitForAssert({-> assert_match('"Xtest_x_arg" \[New\]\[blowfish2\] 1L, 5B written', + \ term_getline(buf, 10))}) + call StopVimInTerminal(buf) + + " Read the encrypted file and check that it contains the expected content "test" + let buf = RunVimInTerminal('-n -x Xtest_x_arg', #{rows: 10, wait_for_ruler: 0}) + call WaitForAssert({-> assert_match('^Enter encryption key: ', term_getline(buf, 10))}) + call term_sendkeys(buf, "foo\n") + call WaitForAssert({-> assert_match('^Enter same key again: ', term_getline(buf, 10))}) + call term_sendkeys(buf, "foo\n") + call WaitForAssert({-> assert_match('^test', term_getline(buf, 1))}) + call StopVimInTerminal(buf) + + call delete('Xtest_x_arg') +endfunc + +" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_tabpage.vim b/src/nvim/testdir/test_tabpage.vim index bc7c69d920..2b6a89647e 100644 --- a/src/nvim/testdir/test_tabpage.vim +++ b/src/nvim/testdir/test_tabpage.vim @@ -1,6 +1,7 @@ " Tests for tabpage source screendump.vim +source check.vim function Test_tabpage() bw! @@ -222,6 +223,34 @@ function Test_tabpage_with_autocmd() 1tabonly! endfunction +" Test autocommands on tab drop +function Test_tabpage_with_autocmd_tab_drop() + augroup TestTabpageGroup + au! + autocmd TabEnter * call add(s:li, 'TabEnter') + autocmd WinEnter * call add(s:li, 'WinEnter') + autocmd BufEnter * call add(s:li, 'BufEnter') + autocmd TabLeave * call add(s:li, 'TabLeave') + autocmd WinLeave * call add(s:li, 'WinLeave') + autocmd BufLeave * call add(s:li, 'BufLeave') + augroup END + + let s:li = [] + tab drop test1 + call assert_equal(['BufLeave', 'BufEnter'], s:li) + + let s:li = [] + tab drop test2 test3 + call assert_equal([ + \ 'TabLeave', 'TabEnter', 'TabLeave', 'TabEnter', + \ 'TabLeave', 'WinEnter', 'TabEnter', 'BufEnter', + \ 'TabLeave', 'WinEnter', 'TabEnter', 'BufEnter'], s:li) + + autocmd! TestTabpageGroup + augroup! TestTabpageGroup + 1tabonly! +endfunction + function Test_tabpage_with_tab_modifier() for n in range(4) tabedit @@ -579,4 +608,82 @@ func Test_tabpage_cmdheight() call delete('XTest_tabpage_cmdheight') endfunc +" Return the terminal key code for selecting a tab page from the tabline. This +" sequence contains the following codes: a CSI (0x9b), KS_TABLINE (0xf0), +" KS_FILLER (0x58) and then the tab page number. +func TabLineSelectPageCode(tabnr) + return "\x9b\xf0\x58" .. nr2char(a:tabnr) +endfunc + +" Return the terminal key code for opening a new tabpage from the tabpage +" menu. This sequence consists of the following codes: a CSI (0x9b), +" KS_TABMENU (0xef), KS_FILLER (0x58), the tab page number and +" TABLINE_MENU_NEW (2). +func TabMenuNewItemCode(tabnr) + return "\x9b\xef\x58" .. nr2char(a:tabnr) .. nr2char(2) +endfunc + +" Return the terminal key code for closing a tabpage from the tabpage menu. +" This sequence consists of the following codes: a CSI (0x9b), KS_TABMENU +" (0xef), KS_FILLER (0x58), the tab page number and TABLINE_MENU_CLOSE (1). +func TabMenuCloseItemCode(tabnr) + return "\x9b\xef\x58" .. nr2char(a:tabnr) .. nr2char(1) +endfunc + +" Test for using the tabpage menu from the insert and normal modes +func Test_tabline_tabmenu() + " only works in GUI + CheckGui + + %bw! + tabnew + tabnew + call assert_equal(3, tabpagenr()) + + " go to tab page 2 in normal mode + call feedkeys(TabLineSelectPageCode(2), "Lx!") + call assert_equal(2, tabpagenr()) + + " close tab page 3 in normal mode + call feedkeys(TabMenuCloseItemCode(3), "Lx!") + call assert_equal(2, tabpagenr('$')) + call assert_equal(2, tabpagenr()) + + " open new tab page before tab page 1 in normal mode + call feedkeys(TabMenuNewItemCode(1), "Lx!") + call assert_equal(1, tabpagenr()) + call assert_equal(3, tabpagenr('$')) + + " go to tab page 2 in operator-pending mode (should beep) + call assert_beeps('call feedkeys("f" .. TabLineSelectPageCode(2), "Lx!")') + + " open new tab page before tab page 1 in operator-pending mode (should beep) + call assert_beeps('call feedkeys("f" .. TabMenuNewItemCode(1), "Lx!")') + + " open new tab page after tab page 3 in normal mode + call feedkeys(TabMenuNewItemCode(4), "Lx!") + call assert_equal(4, tabpagenr()) + call assert_equal(4, tabpagenr('$')) + + " go to tab page 2 in insert mode + call feedkeys("i" .. TabLineSelectPageCode(2) .. "\<C-C>", "Lx!") + call assert_equal(2, tabpagenr()) + + " close tab page 2 in insert mode + call feedkeys("i" .. TabMenuCloseItemCode(2) .. "\<C-C>", "Lx!") + call assert_equal(3, tabpagenr('$')) + + " open new tab page before tab page 3 in insert mode + call feedkeys("i" .. TabMenuNewItemCode(3) .. "\<C-C>", "Lx!") + call assert_equal(3, tabpagenr()) + call assert_equal(4, tabpagenr('$')) + + " open new tab page after tab page 4 in insert mode + call feedkeys("i" .. TabMenuNewItemCode(5) .. "\<C-C>", "Lx!") + call assert_equal(5, tabpagenr()) + call assert_equal(5, tabpagenr('$')) + + %bw! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_textformat.vim b/src/nvim/testdir/test_textformat.vim index 2223be952c..4af52b536c 100644 --- a/src/nvim/testdir/test_textformat.vim +++ b/src/nvim/testdir/test_textformat.vim @@ -424,6 +424,15 @@ func Test_format_align() \ ], getline(1, '$')) enew! + " align text with 'wrapmargin' + 50vnew + call setline(1, ['Vim']) + setl textwidth=0 + setl wrapmargin=30 + right + call assert_equal("\t\t Vim", getline(1)) + q! + set tw& endfunc @@ -931,4 +940,217 @@ func Test_substitute() call assert_equal('a1a2a3a', substitute('123', '\zs', 'a', 'g')) endfunc +" Test for 'a' and 'w' flags in 'formatoptions' +func Test_fo_a_w() + new + setlocal fo+=aw tw=10 + call feedkeys("iabc abc a abc\<Esc>k0weade", 'xt') + call assert_equal(['abc abcde ', 'a abc'], getline(1, '$')) + + " Test for 'a', 'w' and '1' options. + setlocal textwidth=0 + setlocal fo=1aw + %d + call setline(1, '. foo') + normal 72ig + call feedkeys('a uu uu uu', 'xt') + call assert_equal('g uu uu ', getline(1)[-8:]) + call assert_equal(['uu. foo'], getline(2, '$')) + + " using backspace or "x" triggers reformat + call setline(1, ['1 2 3 4 5 ', '6 7 8 9']) + set tw=10 + set fo=taw + set bs=indent,eol,start + exe "normal 1G4la\<BS>\<BS>\<Esc>" + call assert_equal(['1 2 4 5 6 ', '7 8 9'], getline(1, 2)) + exe "normal f4xx" + call assert_equal(['1 2 5 6 7 ', '8 9'], getline(1, 2)) + + set tw=0 + set fo& + %bw! +endfunc + +" Test for formatting lines using gq in visual mode +func Test_visual_gq_format() + new + call setline(1, ['one two three four', 'five six', 'one two']) + setl textwidth=10 + call feedkeys('ggv$jj', 'xt') + redraw! + normal gq + %d + call setline(1, ['one two three four', 'five six', 'one two']) + normal G$ + call feedkeys('v0kk', 'xt') + redraw! + normal gq + setl textwidth& + close! +endfunc + +" Test for 'n' flag in 'formatoptions' to format numbered lists +func Test_fo_n() + new + setlocal autoindent + setlocal textwidth=12 + setlocal fo=n + call setline(1, [' 1) one two three four', ' 2) two']) + normal gggqG + call assert_equal([' 1) one two', ' three', ' four', ' 2) two'], + \ getline(1, '$')) + close! +endfunc + +" Test for 'formatlistpat' option +func Test_formatlistpat() + new + setlocal autoindent + setlocal textwidth=10 + setlocal fo=n + setlocal formatlistpat=^\\s*-\\s* + call setline(1, [' - one two three', ' - two']) + normal gggqG + call assert_equal([' - one', ' two', ' three', ' - two'], + \ getline(1, '$')) + close! +endfunc + +" Test for the 'b' and 'v' flags in 'formatoptions' +" Text should wrap only if a space character is inserted at or before +" 'textwidth' +func Test_fo_b() + new + setlocal textwidth=20 + + setlocal formatoptions=t + call setline(1, 'one two three four') + call feedkeys('Amore', 'xt') + call assert_equal(['one two three', 'fourmore'], getline(1, '$')) + + setlocal formatoptions=bt + %d + call setline(1, 'one two three four') + call feedkeys('Amore five', 'xt') + call assert_equal(['one two three fourmore five'], getline(1, '$')) + + setlocal formatoptions=bt + %d + call setline(1, 'one two three four') + call feedkeys('A five', 'xt') + call assert_equal(['one two three four', 'five'], getline(1, '$')) + + setlocal formatoptions=vt + %d + call setline(1, 'one two three four') + call feedkeys('Amore five', 'xt') + call assert_equal(['one two three fourmore', 'five'], getline(1, '$')) + + close! +endfunc + +" Test for the '1' flag in 'formatoptions'. Don't wrap text after a one letter +" word. +func Test_fo_1() + new + setlocal textwidth=20 + + setlocal formatoptions=t + call setline(1, 'one two three four') + call feedkeys('A a bird', 'xt') + call assert_equal(['one two three four a', 'bird'], getline(1, '$')) + + %d + setlocal formatoptions=t1 + call setline(1, 'one two three four') + call feedkeys('A a bird', 'xt') + call assert_equal(['one two three four', 'a bird'], getline(1, '$')) + + close! +endfunc + +" Test for 'l' flag in 'formatoptions'. When starting insert mode, if a line +" is longer than 'textwidth', then it is not broken. +func Test_fo_l() + new + setlocal textwidth=20 + + setlocal formatoptions=t + call setline(1, 'one two three four five') + call feedkeys('A six', 'xt') + call assert_equal(['one two three four', 'five six'], getline(1, '$')) + + %d + setlocal formatoptions=tl + call setline(1, 'one two three four five') + call feedkeys('A six', 'xt') + call assert_equal(['one two three four five six'], getline(1, '$')) + + close! +endfunc + +" Test for the '2' flag in 'formatoptions' +func Test_fo_2() + new + setlocal autoindent + setlocal formatoptions=t2 + setlocal textwidth=30 + call setline(1, ["\tfirst line of a paragraph.", + \ "second line of the same paragraph.", + \ "third line."]) + normal gggqG + call assert_equal(["\tfirst line of a", + \ "paragraph. second line of the", + \ "same paragraph. third line."], getline(1, '$')) + close! +endfunc + +" Test for formatting lines where only the first line has a comment. +func Test_fo_gq_with_firstline_comment() + new + setlocal formatoptions=tcq + call setline(1, ['- one two', 'three']) + normal gggqG + call assert_equal(['- one two three'], getline(1, '$')) + + %d + call setline(1, ['- one', '- two']) + normal gggqG + call assert_equal(['- one', '- two'], getline(1, '$')) + close! +endfunc + +" Test for trying to join a comment line with a non-comment line +func Test_join_comments() + new + call setline(1, ['one', '/* two */', 'three']) + normal gggqG + call assert_equal(['one', '/* two */', 'three'], getline(1, '$')) + close! +endfunc + +" Test for using 'a' in 'formatoptions' with comments +func Test_autoformat_comments() + new + setlocal formatoptions+=a + call feedkeys("a- one\n- two\n", 'xt') + call assert_equal(['- one', '- two', ''], getline(1, '$')) + + %d + call feedkeys("a\none\n", 'xt') + call assert_equal(['', 'one', ''], getline(1, '$')) + + setlocal formatoptions+=aw + %d + call feedkeys("aone \ntwo\n", 'xt') + call assert_equal(['one two', ''], getline(1, '$')) + + %d + call feedkeys("aone\ntwo\n", 'xt') + call assert_equal(['one', 'two', ''], getline(1, '$')) + + close! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/vim.h b/src/nvim/vim.h index 900f2acd81..01f20cf29a 100644 --- a/src/nvim/vim.h +++ b/src/nvim/vim.h @@ -208,6 +208,7 @@ enum { FOLD_TEXT_LEN = 51 }; //!< buffer size for get_foldtext() // Size in bytes of the hash used in the undo file. #define UNDO_HASH_SIZE 32 +#define CLEAR_POINTER(ptr) memset((ptr), 0, sizeof(*(ptr))) // defines to avoid typecasts from (char_u *) to (char *) and back // (vim_strchr() is now in strings.c) diff --git a/src/nvim/window.c b/src/nvim/window.c index 9eb16e67ec..2dcce2d8cb 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -641,7 +641,7 @@ void win_set_minimal_style(win_T *wp) wp->w_p_scl = (char_u *)xstrdup("auto"); } - // foldcolumn: use 'auto' + // foldcolumn: use '0' if (wp->w_p_fdc[0] != '0') { xfree(wp->w_p_fdc); wp->w_p_fdc = (char_u *)xstrdup("0"); @@ -700,9 +700,10 @@ int win_fdccol_count(win_T *wp) const char *fdc = (const char *)wp->w_p_fdc; // auto:<NUM> - if (strncmp(fdc, "auto:", 5) == 0) { + if (strncmp(fdc, "auto", 4) == 0) { + const int fdccol = fdc[4] == ':' ? fdc[5] - '0' : 1; int needed_fdccols = getDeepestNesting(wp); - return MIN(fdc[5] - '0', needed_fdccols); + return MIN(fdccol, needed_fdccols); } else { return fdc[0] - '0'; } @@ -1636,6 +1637,19 @@ bool win_valid(const win_T *win) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT return false; } +// Find window "handle" in the current tab page. +// Return NULL if not found. +win_T *win_find_by_handle(handle_T handle) + FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT +{ + FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { + if (wp->handle == handle) { + return wp; + } + } + return NULL; +} + /// Check if "win" is a pointer to an existing window in any tabpage. /// /// @param win window to check @@ -4526,7 +4540,7 @@ static void win_enter_ext(win_T *wp, bool undo_sync, int curwin_invalid, // Might need to scroll the old window before switching, e.g., when the // cursor was moved. - update_topline(); + update_topline(curwin); // may have to copy the buffer options when 'cpo' contains 'S' if (wp->w_buffer != curbuf) { @@ -4999,7 +5013,10 @@ void win_size_save(garray_T *gap) { ga_init(gap, (int)sizeof(int), 1); - ga_grow(gap, win_count() * 2); + ga_grow(gap, win_count() * 2 + 1); + // first entry is value of 'lines' + ((int *)gap->ga_data)[gap->ga_len++] = Rows; + FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { ((int *)gap->ga_data)[gap->ga_len++] = wp->w_width + wp->w_vsep_width; @@ -5007,18 +5024,18 @@ void win_size_save(garray_T *gap) } } -/* - * Restore window sizes, but only if the number of windows is still the same. - * Does not free the growarray. - */ +// Restore window sizes, but only if the number of windows is still the same +// and 'lines' didn't change. +// Does not free the growarray. void win_size_restore(garray_T *gap) + FUNC_ATTR_NONNULL_ALL { - if (win_count() * 2 == gap->ga_len) { - /* The order matters, because frames contain other frames, but it's - * difficult to get right. The easy way out is to do it twice. */ - for (int j = 0; j < 2; ++j) - { - int i = 0; + if (win_count() * 2 + 1 == gap->ga_len + && ((int *)gap->ga_data)[0] == Rows) { + // The order matters, because frames contain other frames, but it's + // difficult to get right. The easy way out is to do it twice. + for (int j = 0; j < 2; j++) { + int i = 1; FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { int width = ((int *)gap->ga_data)[i++]; int height = ((int *)gap->ga_data)[i++]; @@ -5859,10 +5876,10 @@ void scroll_to_fraction(win_T *wp, int prev_height) } if (wp == curwin) { - if (get_scrolloff_value()) { - update_topline(); + if (get_scrolloff_value(wp)) { + update_topline(wp); } - curs_columns(false); // validate w_wrow + curs_columns(wp, false); // validate w_wrow } if (prev_height > 0) { wp->w_prev_fraction_row = wp->w_wrow; @@ -5918,8 +5935,8 @@ void win_set_inner_size(win_T *wp) changed_line_abv_curs_win(wp); invalidate_botline_win(wp); if (wp == curwin) { - update_topline(); - curs_columns(true); // validate w_wrow + update_topline(wp); + curs_columns(wp, true); // validate w_wrow } redraw_later(wp, NOT_VALID); } diff --git a/test/functional/api/server_notifications_spec.lua b/test/functional/api/server_notifications_spec.lua index 29cd38ef0d..9ee2570798 100644 --- a/test/functional/api/server_notifications_spec.lua +++ b/test/functional/api/server_notifications_spec.lua @@ -3,6 +3,8 @@ local eq, clear, eval, command, nvim, next_msg = helpers.eq, helpers.clear, helpers.eval, helpers.command, helpers.nvim, helpers.next_msg local meths = helpers.meths +local exec_lua = helpers.exec_lua +local retry = helpers.retry describe('notify', function() local channel @@ -72,4 +74,18 @@ describe('notify', function() nvim('unsubscribe', 'event1') eq(2, eval('1+1')) -- Still alive? end) + + it('cancels stale events on channel close', function() + if helpers.pending_win32(pending) then return end + local catchan = eval("jobstart(['cat'], {'rpc': v:true})") + eq({id=catchan, stream='job', mode='rpc', client = {}}, exec_lua ([[ + vim.rpcnotify(..., "nvim_call_function", 'chanclose', {..., 'rpc'}) + vim.rpcnotify(..., "nvim_subscribe", "daily_rant") + return vim.api.nvim_get_chan_info(...) + ]], catchan)) + eq(2, eval('1+1')) -- Still alive? + eq({false, 'Invalid channel: '..catchan}, + exec_lua ([[ return {pcall(vim.rpcrequest, ..., 'nvim_eval', '1+1')}]], catchan)) + retry(nil, 3000, function() eq({}, meths.get_chan_info(catchan)) end) -- cat be dead :( + end) end) diff --git a/test/functional/eval/api_functions_spec.lua b/test/functional/eval/api_functions_spec.lua index ed110efeb4..7d09a652ba 100644 --- a/test/functional/eval/api_functions_spec.lua +++ b/test/functional/eval/api_functions_spec.lua @@ -47,6 +47,10 @@ describe('eval-API', function() eq('Vim(call):E5555: API call: Invalid buffer id: 17', err) end) + it('cannot change texts if textlocked', function() + command("autocmd TextYankPost <buffer> ++once call nvim_buf_set_lines(0, 0, -1, v:false, [])") + eq('Vim(call):E5555: API call: E523: Not allowed here', pcall_err(command, "normal! yy")) + end) it("use buffer numbers and windows ids as handles", function() local screen = Screen.new(40, 8) diff --git a/test/functional/eval/null_spec.lua b/test/functional/eval/null_spec.lua index fa8f7d873f..bef41e52d4 100644 --- a/test/functional/eval/null_spec.lua +++ b/test/functional/eval/null_spec.lua @@ -121,7 +121,7 @@ describe('NULL', function() null_test('does not make Neovim crash when v:oldfiles gets assigned to that', ':let v:oldfiles = L|oldfiles', 0) null_expr_test('does not make complete() crash or error out', 'execute(":normal i\\<C-r>=complete(1, L)[-1]\\n")', - '', '\n', function() + 0, '', function() eq({''}, curbufmeths.get_lines(0, -1, false)) end) null_expr_test('is accepted by setmatches()', 'setmatches(L)', 0, 0) diff --git a/test/functional/eval/timer_spec.lua b/test/functional/eval/timer_spec.lua index 9ee0735e40..3f57568b8e 100644 --- a/test/functional/eval/timer_spec.lua +++ b/test/functional/eval/timer_spec.lua @@ -130,12 +130,12 @@ describe('timers', function() nvim_async("command", "call timer_start("..load_adjust(100)..", 'AddItem', {'repeat': -1})") screen:expect([[ - ITEM 1 | + ^ITEM 1 | ITEM 2 | {1:~ }| {1:~ }| {1:~ }| - ^ | + | ]]) nvim_async("command", "let g:cont = 1") diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua index 7e4de7c39a..9f2b1b6e52 100644 --- a/test/functional/lua/buffer_updates_spec.lua +++ b/test/functional/lua/buffer_updates_spec.lua @@ -25,14 +25,14 @@ local function attach_buffer(evname) local evname = ... local events = {} - function test_register(bufnr, id, changedtick, utf_sizes) + function test_register(bufnr, id, changedtick, utf_sizes, preview) local function callback(...) table.insert(events, {id, ...}) if test_unreg == id then return true end end - local opts = {[evname]=callback, on_detach=callback, utf_sizes=utf_sizes} + local opts = {[evname]=callback, on_detach=callback, utf_sizes=utf_sizes, preview=preview} if changedtick then opts.on_changedtick = callback end @@ -290,7 +290,7 @@ describe('lua: nvim_buf_attach on_bytes', function() if verify then meths.buf_get_offset(0, meths.buf_line_count(0)) end - exec_lua("return test_register(...)", 0, "test1",false, nil) + exec_lua("return test_register(...)", 0, "test1", false, false, true) meths.buf_get_changedtick(0) local verify_name = "test1" @@ -493,6 +493,23 @@ describe('lua: nvim_buf_attach on_bytes', function() } end) + + it('inccomand=nosplit and substitute', function() + if verify then pending("Verification can't be done when previewing") end + + local check_events = setup_eventcheck(verify, {"abcde"}) + meths.set_option('inccommand', 'nosplit') + + feed ':%s/bcd/' + check_events { + { "test1", "bytes", 1, 3, 0, 1, 1, 0, 3, 3, 0, 0, 0 }; + } + + feed 'a' + check_events { + { "test1", "bytes", 1, 3, 0, 1, 1, 0, 3, 3, 0, 1, 1 }; + } + end) end describe('(with verify) handles', function() diff --git a/test/functional/lua/treesitter_spec.lua b/test/functional/lua/treesitter_spec.lua index f34cbbb65b..e522c339a9 100644 --- a/test/functional/lua/treesitter_spec.lua +++ b/test/functional/lua/treesitter_spec.lua @@ -871,12 +871,12 @@ local hl_query = [[ before_each(function() insert([[ - int x = INT_MAX; - #define READ_STRING(x, y) (char_u *)read_string((x), (size_t)(y)) - #define READ_STRING_OK(x, y) (char_u *)read_string((x), (size_t)(y)) - #define VALUE 0 - #define VALUE1 1 - #define VALUE2 2 +int x = INT_MAX; +#define READ_STRING(x, y) (char_u *)read_string((x), (size_t)(y)) +#define READ_STRING_OK(x, y) (char_u *)read_string((x), (size_t)(y)) +#define VALUE 123 +#define VALUE1 123 +#define VALUE2 123 ]]) end) @@ -891,12 +891,12 @@ local hl_query = [[ eq("table", exec_lua("return type(parser:children().c)")) eq(5, exec_lua("return #parser:children().c:trees()")) eq({ - {0, 2, 7, 0}, -- root tree - {3, 16, 3, 17}, -- VALUE 0 - {4, 17, 4, 18}, -- VALUE1 1 - {5, 17, 5, 18}, -- VALUE2 2 - {1, 28, 1, 67}, -- READ_STRING(x, y) (char_u *)read_string((x), (size_t)(y)) - {2, 31, 2, 70} -- READ_STRING_OK(x, y) (char_u *)read_string((x), (size_t)(y)) + {0, 0, 7, 0}, -- root tree + {3, 14, 3, 17}, -- VALUE 123 + {4, 15, 4, 18}, -- VALUE1 123 + {5, 15, 5, 18}, -- VALUE2 123 + {1, 26, 1, 65}, -- READ_STRING(x, y) (char_u *)read_string((x), (size_t)(y)) + {2, 29, 2, 68} -- READ_STRING_OK(x, y) (char_u *)read_string((x), (size_t)(y)) }, get_ranges()) end) end) @@ -912,15 +912,35 @@ local hl_query = [[ eq("table", exec_lua("return type(parser:children().c)")) eq(2, exec_lua("return #parser:children().c:trees()")) eq({ - {0, 2, 7, 0}, -- root tree - {3, 16, 5, 18}, -- VALUE 0 - -- VALUE1 1 - -- VALUE2 2 - {1, 28, 2, 70} -- READ_STRING(x, y) (char_u *)read_string((x), (size_t)(y)) + {0, 0, 7, 0}, -- root tree + {3, 14, 5, 18}, -- VALUE 123 + -- VALUE1 123 + -- VALUE2 123 + {1, 26, 2, 68} -- READ_STRING(x, y) (char_u *)read_string((x), (size_t)(y)) -- READ_STRING_OK(x, y) (char_u *)read_string((x), (size_t)(y)) }, get_ranges()) end) end) + + describe("when using the offset directive", function() + it("should shift the range by the directive amount", function() + exec_lua([[ + parser = vim.treesitter.get_parser(0, "c", { + queries = { + c = "(preproc_def ((preproc_arg) @c (#offset! @c 0 2 0 -1))) (preproc_function_def value: (preproc_arg) @c)"}}) + ]]) + + eq("table", exec_lua("return type(parser:children().c)")) + eq({ + {0, 0, 7, 0}, -- root tree + {3, 15, 3, 16}, -- VALUE 123 + {4, 16, 4, 17}, -- VALUE1 123 + {5, 16, 5, 17}, -- VALUE2 123 + {1, 26, 1, 65}, -- READ_STRING(x, y) (char_u *)read_string((x), (size_t)(y)) + {2, 29, 2, 68} -- READ_STRING_OK(x, y) (char_u *)read_string((x), (size_t)(y)) + }, get_ranges()) + end) + end) end) describe("when getting the language for a range", function() @@ -944,4 +964,52 @@ int x = INT_MAX; eq(result, true) end) end) + + describe("when getting/setting match data", function() + describe("when setting for the whole match", function() + it("should set/get the data correctly", function() + insert([[ + int x = 3; + ]]) + + local result = exec_lua([[ + local result + + query = vim.treesitter.parse_query("c", '((number_literal) @number (#set! "key" "value"))') + parser = vim.treesitter.get_parser(0, "c") + + for pattern, match, metadata in query:iter_matches(parser:parse()[1]:root(), 0, 0, 1) do + result = metadata.key + end + + return result + ]]) + + eq(result, "value") + end) + end) + + describe("when setting for a capture match", function() + it("should set/get the data correctly", function() + insert([[ + int x = 3; + ]]) + + local result = exec_lua([[ + local result + + query = vim.treesitter.parse_query("c", '((number_literal) @number (#set! @number "key" "value"))') + parser = vim.treesitter.get_parser(0, "c") + + for pattern, match, metadata in query:iter_matches(parser:parse()[1]:root(), 0, 0, 1) do + result = metadata[pattern].key + end + + return result + ]]) + + eq(result, "value") + end) + end) + end) end) diff --git a/test/functional/provider/clipboard_spec.lua b/test/functional/provider/clipboard_spec.lua index 1431054494..2c681eb9d8 100644 --- a/test/functional/provider/clipboard_spec.lua +++ b/test/functional/provider/clipboard_spec.lua @@ -605,10 +605,10 @@ describe('clipboard (with fake clipboard.vim)', function() {0:~ }| {4: }| :registers | - {1:--- Registers ---} | - "* some{2:^J}star data{2:^J} | - "+ such{2:^J}plus{2:^J}stuff | - ": let g:test_clip['+'] = ['such', 'plus', 'stuff'] | + {1:Type Name Content} | + l "* some{2:^J}star data{2:^J} | + c "+ such{2:^J}plus{2:^J}stuff | + c ": let g:test_clip['+'] = ['such', 'plus', 'stuff'] | {3:Press ENTER or type command to continue}^ | ]], { [0] = {bold = true, foreground = Screen.colors.Blue}, diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 32f9ae030f..8d654f6e5b 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -5344,6 +5344,45 @@ describe('floatwin', function() -- at least. Also check invisible EndOfBuffer region blends correctly. meths.buf_set_lines(buf, 0, -1, true, {" x x x xx", " x x x x"}) win = meths.open_win(buf, false, {relative='editor', width=12, height=3, row=0, col=11, style='minimal'}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [2:----------------------------------------]| + [3:----------------------------------------]| + ## grid 2 + # TODO: 测试字典信息的准确性 | + # FIXME: 测试字典信息的准确^性 | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + ## grid 3 + | + ## grid 6 + {1: x x x xx}| + {1: x x x x}| + {1: }| + ]], float_pos={ + [6] = { { + id = 1003 + }, "NW", 1, 0, 11, true } + }} + else + screen:expect{grid=[[ + # TODO: 测 {1: x x x xx} 确性 | + # FIXME: 测{1: x x x x}准确^性 | + {0:~ }{1: }{0: }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]} + end meths.win_set_option(win, 'winblend', 30) screen:set_default_attr_ids({ [1] = {foreground = tonumber('0xb282b2'), background = tonumber('0xffcfff')}, @@ -5381,7 +5420,7 @@ describe('floatwin', function() }, "NW", 1, 0, 11, true } }} else - screen:expect([[ + screen:expect{grid=[[ # TODO: 测 {2: x x x}{1:息}{2: xx} 确性 | # FIXME: 测{1:试}{2:x x x}{1:息}{2: x}准确^性 | {3:~ }{4: }{3: }| @@ -5389,7 +5428,7 @@ describe('floatwin', function() {3:~ }| {3:~ }| | - ]]) + ]]} end meths.win_set_config(win, {relative='editor', row=0, col=12}) diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index 7b05e90459..6ce8b33a63 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -886,6 +886,41 @@ describe("folded lines", function() | ]]) end + command("set foldcolumn=auto") + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [3:---------------------------------------------]| + ## grid 2 + {7:+}{5:^+-- 2 lines: line 1························}| + {7: }line 3 | + {7: }line 4 | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + | + ]], unchanged=true} + else + screen:expect{grid=[[ + {7:+}{5:^+-- 2 lines: line 1························}| + {7: }line 3 | + {7: }line 4 | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]], unchanged=true} + end -- fdc should not change with a new fold as the maximum is 1 feed("zf3j") @@ -924,6 +959,41 @@ describe("folded lines", function() ]]) end + command("set foldcolumn=auto:1") + if multigrid then screen:expect{grid=[[ + ## grid 1 + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [3:---------------------------------------------]| + ## grid 2 + {7:+}{5:^+-- 4 lines: line 1························}| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + | + ]], unchanged=true} + else + screen:expect{grid=[[ + {7:+}{5:^+-- 4 lines: line 1························}| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]], unchanged=true} + end + -- relax the maximum fdc thus fdc should expand to -- accomodate the current number of folds command("set foldcolumn=auto:4") diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index 8fa9fcc42f..5104c58796 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -807,7 +807,9 @@ function Screen:_handle_mouse_off() end function Screen:_handle_mode_change(mode, idx) - assert(mode == self._mode_info[idx+1].name) + if self._mode_info ~= nil then + assert(mode == self._mode_info[idx+1].name) + end self.mode = mode end diff --git a/test/functional/ui/searchhl_spec.lua b/test/functional/ui/searchhl_spec.lua index 222275eb4d..3bb72303bf 100644 --- a/test/functional/ui/searchhl_spec.lua +++ b/test/functional/ui/searchhl_spec.lua @@ -20,6 +20,8 @@ describe('search highlighting', function() [2] = {background = colors.Yellow}, -- Search [3] = {reverse = true}, [4] = {foreground = colors.Red}, -- Message + [5] = {bold = true, reverse = true}, + [6] = {foreground = Screen.colors.Blue4, background = Screen.colors.LightGrey}, -- Folded }) end) @@ -38,6 +40,21 @@ describe('search highlighting', function() ]]) end) + it('is disabled in folded text', function() + insert("some text\nmore text") + feed_command('1,2fold') + feed("gg/text") + screen:expect([[ + {6:+-- 2 lines: some text·················}| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + /text^ | + ]]) + end) + it('works', function() insert([[ some text @@ -159,7 +176,15 @@ describe('search highlighting', function() ]]) feed('/foo') helpers.poke_eventloop() - screen:expect_unchanged() + screen:expect{grid=[[ + {3:foo} bar baz {3:│} | + bar baz {2:foo} {3:│} | + bar {2:foo} baz {3:│} | + {3:│} | + {1:~ }{3:│} | + {5:[No Name] [+] }{3:term }| + /foo^ | + ]]} end) it('works with incsearch', function() diff --git a/test/functional/ui/sign_spec.lua b/test/functional/ui/sign_spec.lua index 0ed62b21b2..d1b8de5e4e 100644 --- a/test/functional/ui/sign_spec.lua +++ b/test/functional/ui/sign_spec.lua @@ -76,6 +76,28 @@ describe('Signs', function() ]]) end) + it('allows signs with no text', function() + feed('ia<cr>b<cr><esc>') + command('sign define piet1 text= texthl=Search') + command('sign place 1 line=1 name=piet1 buffer=1') + screen:expect([[ + a | + b | + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + end) + it('can be called right after :split', function() feed('ia<cr>b<cr>c<cr><esc>gg') -- This used to cause a crash due to :sign using a special redraw @@ -244,6 +266,50 @@ describe('Signs', function() ]]} end) + it('ignores signs with no icon and text when calculting the signcolumn width', function() + feed('ia<cr>b<cr>c<cr><esc>') + command('set number') + command('set signcolumn=auto:2') + command('sign define pietSearch text=>> texthl=Search') + command('sign define pietError text= texthl=Error') + command('sign place 2 line=1 name=pietError buffer=1') + -- no signcolumn with only empty sign + screen:expect([[ + {6: 1 }a | + {6: 2 }b | + {6: 3 }c | + {6: 4 }^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + -- single column with 1 sign with text and one sign without + command('sign place 1 line=1 name=pietSearch buffer=1') + screen:expect([[ + {1:>>}{6: 1 }a | + {2: }{6: 2 }b | + {2: }{6: 3 }c | + {2: }{6: ^4 } | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + | + ]]) + end) + it('can have 32bit sign IDs', function() command('sign define piet text=>> texthl=Search') command('sign place 100000 line=1 name=piet buffer=1') |