clangd / vscode-clangd

Visual Studio Code extension for clangd
https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd
MIT License
594 stars 97 forks source link

clangd formatting some part of line to next line #545

Closed lakshits11 closed 8 months ago

lakshits11 commented 8 months ago

Please describe the problem. For hints on what information is helpful, see: https://clangd.llvm.org/troubleshooting.html

If you can, provide a minimal chunk of code that shows the problem (either inline, or attach it if larger).

Suppose I have a line 37 of code like this:

image

Now if I format the code, some part of line 37 is automatically sent to next line

image

why does it happen? Below are my .clang-format settings:

BasedOnStyle: LLVM
UseTab: Never
IndentWidth: 4
TabWidth: 4
BreakBeforeBraces: Allman
AllowShortIfStatementsOnASingleLine: false
IndentCaseLabels: false
ColumnLimit: 0
AccessModifierOffset: -4
NamespaceIndentation: All
FixNamespaceComments: false
AlignConsecutiveMacros: true

I also have word wrap set to off in vscode settings.

Logs Please attach the clangd log from the "Output" window if you can. If possible, run with --log=verbose - note that the logs will include the contents of open files!

System information Clangd version (from the log, or clangd --version): 14.0.6 clangd extension version: 0.1.24 Operating system: Windows 11

i-ky commented 8 months ago

Duplicates https://github.com/llvm/llvm-project/issues/44363.

HighCommander4 commented 8 months ago

Duplicates llvm/llvm-project#44363.

Thanks!

Looks like this was fixed a few days ago so a fix should appear in clangd 18.

lakshits11 commented 8 months ago

So do I need to update my clangd version? I thought maybe extension will fix the issue without need of updating clangd version.

i-ky commented 8 months ago

So do I need to update my clangd version?

Yes, you will need to wait until clangd 18 is released, grab a weekly release from GitHub or build it yourself from source to get the latest fixes.