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

Auto-closing backticks does not work well combined with triple backtick code blocks. #16051

Closed
Yurihaia opened this issue Dec 8, 2023 · 3 comments · Fixed by #17051
Closed
Labels
C-bug Category: bug

Comments

@Yurihaia
Copy link

Yurihaia commented Dec 8, 2023

rust-analyzer version: 0.3.1756-standalone

rustc version: rustc 1.75.0-beta.5

When writing doc comments with examples, attempting to create a code block by pressing backtick three times ends up creating 4 backticks, which can get quite annoying when writing a lot of them.

Furthermore, unlike normal string literals, extra backticks are not error highlighted of course, which means documentation
can end up with random double backticks scattered throughout the documentation.

Ideally I would line an option to at least disable the autoclosing backticks without having to disable all autoclosing pairs, because any more sophisticated solution will still run into the second issue.

@Yurihaia Yurihaia added the C-bug Category: bug label Dec 8, 2023
@lnicola
Copy link
Member

lnicola commented Dec 8, 2023

This is caused by #15668, which kinda' makes sense. It's a bit annoying, but I'm not a fan of auto-closing brackets so I don't know.

@Veykril
Copy link
Member

Veykril commented Dec 8, 2023

That is indeed annoying and we can't make it work for that situation either. Rather than a config I think we should remove autoclosing for backticks again, making it configurable means we can't use the config file there altogether I think (or at least is gonna be annoying as parts of it are then defined in code, and other parts are not).

@roife
Copy link
Member

roife commented Apr 8, 2024

Perhaps we can add ``` to the configuration file; here's an example (I press backtick for three times and it automatically completes three backticks):

Untitled-2

If we want to add diagnostics for markdown, we should process it server-side. However, I'm not sure if this should be handled by rust-analyzer.

If this solution is acceptable for you, I can submit a PR and close this issue.👀

@bors bors closed this as completed in e1d7ce7 Apr 13, 2024
lnicola pushed a commit to lnicola/rust that referenced this issue Apr 20, 2024
…ks, r=Veykril

fix: support auto-closing for triple backticks

It might fix rust-lang#16051, see rust-lang/rust-analyzer#16051 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants