Skip to content

bug: hover display has linebreak, when the hover window is narrow #408

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

Closed
2 tasks done
kmoschcau opened this issue Apr 23, 2025 · 2 comments
Closed
2 tasks done

bug: hover display has linebreak, when the hover window is narrow #408

kmoschcau opened this issue Apr 23, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@kmoschcau
Copy link

Neovim version (nvim -v)

v0.12.0-dev-197+g1dbede5b93

Neovim distribution

N/A

Operating system

Windows 11

Terminal emulator / GUI

WezTerm / Neovide

Describe the bug

When the hover content is really narrow, the rendered markdown is wider than the window width and introduces a line break. This means I have to go into the hover window to see what it wants to show me.

Here is a screenshot of the issue:
Image

󰛦 typescript
↪

Here is a screenshot of the hover buffer contents:
Image

\`\`\`typescript
const key: string
\`\`\`

(The cursor is on the first line in the first column. The closing backticks for the code block are off-screen.)

The issue seems to be only the first line. When I put my cursor there or scroll it off-screen, everything works as expected.

Expected behavior

The first line should be narrow enough, that it does not break across lines.

Healthcheck output

==============================================================================
render-markdown:                                                          1 ⚠️

render-markdown.nvim [version] ~
- ✅ OK plugin 8.3.5
- ✅ OK neovim >= 0.11

render-markdown.nvim [configuration] ~
- ✅ OK valid

render-markdown.nvim [treesitter] ~
- ✅ OK markdown: parser installed
- ✅ OK markdown_inline: parser installed
- ✅ OK latex: parser installed
- ✅ OK html: parser installed
- ✅ OK markdown: highlight enabled

render-markdown.nvim [icons] ~
- ✅ OK using: mini.icons

render-markdown.nvim [executables] ~
- ⚠️ WARNING latex2text: not installed
  - ADVICE:
    - Disable latex support to avoid this warning
    - require('render-markdown').setup({ latex = { enabled = false } })

render-markdown.nvim [conflicts] ~
- ✅ OK headlines: not installed
- ✅ OK markview: not installed
- ✅ OK obsidian: not installed

Plugin configuration

Default Configuration

Plugin error log

N/A

Confirmations

  • I have updated this plugin to the latest version using my plugin manager
  • I have provided the text contained in all screenshots as raw text in this issue. This means if there is a screenshot below it is the copy pasted contents of the file in the screenshot. I understand that my issue will be closed if I have not.

Additional information

No response

@kmoschcau kmoschcau added the bug Something isn't working label Apr 23, 2025
MeanderingProgrammer added a commit that referenced this issue Apr 23, 2025
## Details

Issue: #408

For narrow windows adding the language icon above code blocks can lead
to text wrapping which will lead to an extra line under the code block.

There are really only 2 ways to fix this:

1. Increase the window width such that it is wide enough to avoid wrapping.
2. Disable line wrapping.

In the first case we end up needing to accurately calculate the width we
need to avoid the line wrapping and also check that the new width does
not cause the window to flow out of bounds. There's lots of edge cases
to these and the end result doesn't look particularly great since it'll
add extra space off the side of these narrow doc buffers.

So instead we take the much simpler approach of disabling line wrapping
on these buffers, however we do this only when the content in the buffer
does not need line wrapping, i.e. the width of the longest line is <=
the width of the window. This should work for most situations but I'm
sure there will be some edge cases to it.
@MeanderingProgrammer
Copy link
Owner

Thanks for letting me know!

This is another symptom of concealed text still taking up vertical space, even if it's not needed.

Should be resolved by: 080104e

It's hacky but should do the trick.

@kmoschcau
Copy link
Author

That did it. Thank you.

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

2 participants