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

newlines are stripped from show_line_diagnostics content #1502

Open
flrgh opened this issue Nov 15, 2024 · 1 comment
Open

newlines are stripped from show_line_diagnostics content #1502

flrgh opened this issue Nov 15, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@flrgh
Copy link

flrgh commented Nov 15, 2024

Describe the bug

Hi there 👋

I've noticed that newlines are stripped from diagnostic messages from show_line_diagnostics, which can render them distorted/unreadable in some cases.

Steps to reproduce

min.lua
vim.opt.rtp:append('~/.local/share/nvim/lazy/lspsaga.nvim')
vim.opt.rtp:append('~/.local/share/nvim/lazy/nvim-lspconfig')

local lspconfig = require('lspconfig')

-- setup rust-analyzer with default config
lspconfig.rust_analyzer.setup({})

-- don't show inline diagnostics
vim.diagnostic.enable(false)

require('lspsaga').setup({})
main.rs
fn demo(arg: String) {
    println!("{arg}");
}

fn main() {
    let s = "my string".to_string();
    demo(s);
    demo(s);
}
nvim --clean -u min.lua main.rs

Expected behavior

Here's an example from rust-analyzer where the message contents are:

use of moved value: `s`\nvalue used here after move"

vim.diagnostic.open_float()

The builtin diagnostic float handler preserves the newline, as expected.

screenshot

image

Lspsaga show_line_diagnostics

Lspsaga strips the newline before rendering.

screenshot (minimal)

image

The minimum repro example is still somewhat readable, but in my full config where the ` is hidden by the markdown render process (not sure why--different problem I guess), things get even less readable:

screenshot (full)

image

Neovim version (nvim -v)

0.10.2

lspsaga commit

d027f8b

Terminal name/version

alacritty 0.14.0

@flrgh flrgh added the bug Something isn't working label Nov 15, 2024
@flrgh
Copy link
Author

flrgh commented Nov 15, 2024

I'm sympathetic to the fact that the message we're receiving from rust-analyzer is not super great. The purpose of the newline in the message is kind of ambiguous, making it difficult for lspsaga to decide how to consume the message. If the newline is intended to be a line break that separates two distinct statements, it's probably "significant" and shouldn't be stripped, but if it's just text-wrapping that survives from the source material then a renderer/consumer should be able to treat it as superfluous and strip it away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant