Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: split diagnostic lines on \n character in floating window #1438

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions lua/lspsaga/diagnostic/show.lua
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ function sd:show(opt)
curnode.expand = true
for i, entry in ipairs(curnode.diags) do
local virt_start = i == #curnode.diags and ui.lines[1] or ui.lines[2]
local mes = msg_fmt(entry)

if i == 1 then
---@diagnostic disable-next-line: param-type-mismatch
local fname = fn.fnamemodify(api.nvim_buf_get_name(tonumber(entry.bufnr)), ':t')
Expand All @@ -310,8 +310,26 @@ function sd:show(opt)
count = count + 1
curnode.lnum = count
end
self:write_line(mes, entry.severity, virt_start, count)
count = count + 1

local messages = vim.split(entry.message, '\n')
for j, message in ipairs(messages) do
local mes = ''
if j == 1 then
mes = msg_fmt({
message = message,
lnum = entry.lnum,
col = entry.col,
bufnr = entry.bufnr,
source = entry.source,
code = entry.code,
})
else
mes = ' ' .. message
end

self:write_line(mes, entry.severity, virt_start, count)
count = count + 1
end
end
curnode = curnode.next
end
Expand Down