From e34e2289c22834239e0522b7331f17fdfb3705e0 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Fri, 4 Jul 2025 17:29:51 +0100 Subject: [PATCH] fix(diagnostic): fix flaky error --- runtime/lua/vim/diagnostic.lua | 9 +++++---- runtime/lua/vim/treesitter/_fold.lua | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua index bed91d3a1b..33d0be9e95 100644 --- a/runtime/lua/vim/diagnostic.lua +++ b/runtime/lua/vim/diagnostic.lua @@ -2600,16 +2600,17 @@ function M.match(str, pat, groups, severity_map, defaults) return end - local diagnostic = {} + local diagnostic = {} --- @type table for i, match in ipairs(matches) do local field = groups[i] if field == 'severity' then - match = severity_map[match] + diagnostic[field] = severity_map[match] elseif field == 'lnum' or field == 'end_lnum' or field == 'col' or field == 'end_col' then - match = assert(tonumber(match)) - 1 + diagnostic[field] = assert(tonumber(match)) - 1 + elseif field then + diagnostic[field] = match end - diagnostic[field] = match --- @type any end diagnostic = vim.tbl_extend('keep', diagnostic, defaults or {}) --- @type vim.Diagnostic diff --git a/runtime/lua/vim/treesitter/_fold.lua b/runtime/lua/vim/treesitter/_fold.lua index 1064004320..8997341233 100644 --- a/runtime/lua/vim/treesitter/_fold.lua +++ b/runtime/lua/vim/treesitter/_fold.lua @@ -169,6 +169,7 @@ local function compute_folds_levels(bufnr, info, srow, erow, callback) -- If this line ends a fold f1 and starts a fold f2, then move f1's end to the previous line -- so that f2 gets the correct level on this line. This may reduce the size of f1 below -- foldminlines, but we don't handle it for simplicity. + --- @type integer avoid flaky error adjusted = level0 - leave_line leave_line = 0 end