markdown: Fix visible escape characters in LSP diagnostics#51766
Conversation
smitbarmase
left a comment
There was a problem hiding this comment.
Thanks, I think we should not strip the leading whitespace since it might lead to stylistic changes that LSP didn't advertise. Can we replace these whitespaces with so that Markdown renderer still adds those intended spacing, without turning it into a codeblock?
0b6b88f to
525f642
Compare
Just adjusted as you requested! |
smitbarmase
left a comment
There was a problem hiding this comment.
Thanks, I made a couple of fixes here:
-
Tabs in leading whitespace were getting replaced with a single non-breaking space instead of 4. This means tab-indented diagnostics would look collapsed. Fixed it by expanding each tab to 4 NBSPs.
-
String::with_capacitywas underestimating. It accounted for doubled newlines and backslash prefixes but missed the NBSP expansion (each\u{00A0}is 2 bytes in UTF-8 vs 1 for the original space/tab). The capacity is now computed exactly upfront.
I think now it is in right shape! Thanks again.
Replace leading whitespace with U+00A0 (non-breaking space) instead of stripping it, so markdown won't trigger indented code blocks while still preserving the visual indentation that LSP diagnostics intended.
add markdown escaper
808a065 to
bf05143
Compare
Closes #51622 Before you mark this PR as ready for review, make sure that you have: - [x] Added a solid test coverage and/or screenshots from doing manual testing - [x] Done a self-review taking into account security and performance aspects - [ ] Aligned any UI changes with the [UI checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) Release Notes: - Fixed markdown escape characters being visible in LSP diagnostic messages when leading whitespace caused indented code blocks --------- Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
…tries#51766) Closes zed-industries#51622 Before you mark this PR as ready for review, make sure that you have: - [x] Added a solid test coverage and/or screenshots from doing manual testing - [x] Done a self-review taking into account security and performance aspects - [ ] Aligned any UI changes with the [UI checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) Release Notes: - Fixed markdown escape characters being visible in LSP diagnostic messages when leading whitespace caused indented code blocks --------- Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
Closes #51622
Before you mark this PR as ready for review, make sure that you have:
Release Notes: