diff options
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/doc/diagnostic.txt | 3 | ||||
-rw-r--r-- | runtime/lua/vim/diagnostic.lua | 4 |
2 files changed, 4 insertions, 3 deletions
diff --git a/runtime/doc/diagnostic.txt b/runtime/doc/diagnostic.txt index 437778574d..b7d5cb0b2c 100644 --- a/runtime/doc/diagnostic.txt +++ b/runtime/doc/diagnostic.txt @@ -373,7 +373,8 @@ Lua module: vim.diagnostic *diagnostic-api* Fields: ~ • {namespace}? (`integer[]|integer`) Limit diagnostics to one or more namespaces. - • {lnum}? (`integer`) Limit diagnostics to the given line number. + • {lnum}? (`integer`) Limit diagnostics to those spanning the + specified line number. • {severity}? (`vim.diagnostic.SeverityFilter`) See |diagnostic-severity|. diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua index 7371b5241f..b42eece4c2 100644 --- a/runtime/lua/vim/diagnostic.lua +++ b/runtime/lua/vim/diagnostic.lua @@ -717,7 +717,7 @@ local function get_diagnostics(bufnr, opts, clamp) ---@param b integer ---@param d vim.Diagnostic local function add(b, d) - if not opts.lnum or d.lnum == opts.lnum then + if not opts.lnum or (opts.lnum >= d.lnum and opts.lnum <= (d.end_lnum or d.lnum)) then if clamp and api.nvim_buf_is_loaded(b) then local line_count = buf_line_count[b] - 1 if @@ -1140,7 +1140,7 @@ end --- Limit diagnostics to one or more namespaces. --- @field namespace? integer[]|integer --- ---- Limit diagnostics to the given line number. +--- Limit diagnostics to those spanning the specified line number. --- @field lnum? integer --- --- See |diagnostic-severity|. |