aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/lua/vim')
-rw-r--r--runtime/lua/vim/lsp/diagnostic.lua2
-rw-r--r--runtime/lua/vim/shared.lua11
2 files changed, 9 insertions, 4 deletions
diff --git a/runtime/lua/vim/lsp/diagnostic.lua b/runtime/lua/vim/lsp/diagnostic.lua
index 41a62da522..ccd325b1ac 100644
--- a/runtime/lua/vim/lsp/diagnostic.lua
+++ b/runtime/lua/vim/lsp/diagnostic.lua
@@ -449,7 +449,7 @@ end
--- endif
--- return sl
--- endfunction
---- let &l:statusline = '%#MyStatuslineLSP#LSP '.LspStatus()
+--- autocmd BufWinEnter * let &l:statusline = '%#MyStatuslineLSP#LSP '.LspStatus()
--- </pre>
---
---@param bufnr number The buffer number
diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua
index 032b2b2cb5..18c1e21049 100644
--- a/runtime/lua/vim/shared.lua
+++ b/runtime/lua/vim/shared.lua
@@ -267,18 +267,23 @@ function vim.tbl_deep_extend(behavior, ...)
end
--- Deep compare values for equality
+---
+--- Tables are compared recursively unless they both provide the `eq` methamethod.
+--- All other types are compared using the equality `==` operator.
+---@param a first value
+---@param b second value
+---@returns `true` if values are equals, else `false`.
function vim.deep_equal(a, b)
if a == b then return true end
if type(a) ~= type(b) then return false end
if type(a) == 'table' then
- -- TODO improve this algorithm's performance.
for k, v in pairs(a) do
if not vim.deep_equal(v, b[k]) then
return false
end
end
- for k, v in pairs(b) do
- if not vim.deep_equal(v, a[k]) then
+ for k, _ in pairs(b) do
+ if a[k] == nil then
return false
end
end