-
Notifications
You must be signed in to change notification settings - Fork 118
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
An additional new line is being inserted (windows) #759
Comments
I can't reproduce this on Linux, even after running the input file through Can you share a verbose clangd log? |
|
I wouldn't be surprised to see that this is a Windows-only issue |
The log you shared doesn't include the If possible, logs starting at clangd startup are ideal. |
|
Thanks; I am able to reproduce the issue on Linux now, with an input file containing Looking at the server's response to {
"id": 8,
"jsonrpc": "2.0",
"result": [
{
"newText": "#include \"a.h\"\r\n#include \"b.h\"\r\n#include \"c.h\"\r",
"range": {
"end": {
"character": 15,
"line": 2
},
"start": {
"character": 0,
"line": 0
}
}
}
]
} The range to replace ends at line 2, character 15, which includes the This certainly seems a bit odd (why include the Naively, it seems to me that replacing a character range ending with |
The code that applies the formatting edits is not in vscode-clangd, but in vscode itself. vscode-clangd includes the vscode-languageclient library, which implements the client-side handling of LSP protocol messages, and translates them to appropriate calls to the vscode extension API. For the The code that applies the edits is in vscode itself (in the repo https://github.com/microsoft/vscode); I haven't tracked it down, but a starting point to do so would be to find the implementation of the |
I've checked the internals of clang-format and it simply doesn't care about \r, it considers is just a character in a line which starts with |
I've logged an issue with VS Code, we'll see when they fix it |
Please describe the problem.
This is the issue described at xaverh/vscode-clang-format#84
Config:
The code:
Each time you format using clangd, a new line is added before the using namespace. I checked if I can remove the \r from the replacement in the formatting code, though it breaks other stuff while doing so. (clang-format.exe now reformats as it tries to remove the \r)
I couldn't find the code in the extension that applies these changes, though we'll have to remove the \r at the end (if it exists) before applying the replacement.
The text was updated successfully, but these errors were encountered: