Skip to content

fix(lsp): prevent duplicate trailing punctuation in clangd #2003

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
wants to merge 1 commit into from

Conversation

soifou
Copy link
Collaborator

@soifou soifou commented Jul 18, 2025

Strip the trailing angle bracket or quote from clangd file completion items to avoid duplicated characters.

This issue is a side effect of the recent change in compensate_for_cursor_movement (hope this is the only one). Clangd deliberately includes the closing punctuation in all "file" completion candidates. This behavior is opinionated and there is currently no way to opt out (see clangd/clangd#2277).

While it bothers me to add this downstream workaround, I believe it is reasonable to let users handle the closing character themselves—either manually or via a pairs plugin as they do when using the "path" source or from other lsp.

Feel free to close this PR if you think there is a better solution.

Closes #1989

Strip the trailing angle bracket or quote from clangd file completion
items to avoid duplicated characters.

Closes #1989
@lixiao189
Copy link

Look at this reply: clangd/clangd#1041 (comment)
I think that the better way is to replace the inserted text with LSP suggestion item instead of stripping the text in the end?

@Saghen
Copy link
Owner

Saghen commented Jul 21, 2025

As mentioned by the clangd folks, the replace range sent at the time of the request is correct, so we should try to fix the root cause in the compensate_for_cursor_movement. Quite a tricky one to get right...

Fyi, I believe the issue with disable-next-line is actually a lua-ls issue: #1985 (comment)

@Saghen Saghen closed this Jul 21, 2025
@soifou soifou deleted the fix/clangd-ending-punctuation branch July 21, 2025 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clangd #include snippet completion result in extra brackets or qoutes
3 participants