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

An additional new line is being inserted (windows) #759

Open
JVApen opened this issue Dec 16, 2024 · 9 comments
Open

An additional new line is being inserted (windows) #759

JVApen opened this issue Dec 16, 2024 · 9 comments
Labels
bug Something isn't working

Comments

@JVApen
Copy link
Contributor

JVApen commented Dec 16, 2024

Please describe the problem.

This is the issue described at xaverh/vscode-clang-format#84

Config:

IncludeBlocks: Regroup
SortIncludes: 'true'

The code:

#include "a.h"
#include "c.h"
#include "b.h"

using namespace NS;

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.

@JVApen JVApen added the bug Something isn't working label Dec 16, 2024
@HighCommander4
Copy link
Contributor

I can't reproduce this on Linux, even after running the input file through unix2dos (so it has CRLF line endings).

Can you share a verbose clangd log?

@JVApen
Copy link
Contributor Author

JVApen commented Dec 17, 2024

V[09:09:51.654] <<< {"id":1,"jsonrpc":"2.0","method":"textDocument/codeAction","params":{"context":{"diagnostics":[],"triggerKind":2},"range":{"end":{"character":0,"line":0},"start":{"character":0,"line":0}},"textDocument":{"uri":"file:///e%3A/checkout/test.h"}}}

I[09:09:51.654] <-- textDocument/codeAction(1)
V[09:09:51.654] <<< {"id":2,"jsonrpc":"2.0","method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"file:///e%3A/checkout/test.h"}}}

I[09:09:51.654] <-- textDocument/documentSymbol(2)
V[09:09:51.655] config note at e:\checkout\.clangd:2:0: Parsing config fragment
V[09:09:51.655] config note at e:\checkout\.clangd:1:0: Parsed 1 fragments from file
V[09:09:51.655] Config fragment: compiling e:\checkout\.clangd:2 -> 0x0000020AECE90BE0 (trusted=false)
I[09:09:51.655] --> textDocument/publishDiagnostics
V[09:09:51.656] >>> {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[],"uri":"file:///e:/checkout/.clangd"}}

V[09:09:51.656] ASTWorker running EnumerateTweaks on version 1 of e:\checkout\test.h
I[09:09:51.656] --> reply:textDocument/codeAction(1) 1 ms
V[09:09:51.656] >>> {"id":1,"jsonrpc":"2.0","result":[]}

V[09:09:51.656] ASTWorker running DocumentSymbols on version 1 of e:\checkout\test.h
I[09:09:51.656] --> reply:textDocument/documentSymbol(2) 1 ms
V[09:09:51.656] >>> {"id":2,"jsonrpc":"2.0","result":[]}

I[09:09:51.656] --> textDocument/clangd.fileStatus
V[09:09:51.656] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///e:/checkout/test.h"}}

V[09:09:51.930] <<< {"id":3,"jsonrpc":"2.0","method":"textDocument/inlayHint","params":{"range":{"end":{"character":0,"line":5},"start":{"character":0,"line":0}},"textDocument":{"uri":"file:///e%3A/checkout/test.h"}}}

I[09:09:51.931] <-- textDocument/inlayHint(3)
V[09:09:51.931] ASTWorker running InlayHints on version 1 of e:\checkout\test.h
I[09:09:51.931] --> reply:textDocument/inlayHint(3) 0 ms
V[09:09:51.931] >>> {"id":3,"jsonrpc":"2.0","result":[]}

I[09:09:51.931] --> textDocument/clangd.fileStatus
V[09:09:51.931] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///e:/checkout/test.h"}}

V[09:09:51.931] <<< {"id":4,"jsonrpc":"2.0","method":"textDocument/documentLink","params":{"textDocument":{"uri":"file:///e%3A/checkout/test.h"}}}

I[09:09:51.931] <-- textDocument/documentLink(4)
V[09:09:51.931] ASTWorker running DocumentLinks on version 1 of e:\checkout\test.h
I[09:09:51.931] --> reply:textDocument/documentLink(4) 0 ms
V[09:09:51.931] >>> {"id":4,"jsonrpc":"2.0","result":[]}

I[09:09:51.931] --> textDocument/clangd.fileStatus
V[09:09:51.931] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///e:/checkout/test.h"}}

V[09:09:51.946] <<< {"id":5,"jsonrpc":"2.0","method":"textDocument/foldingRange","params":{"textDocument":{"uri":"file:///e%3A/checkout/test.h"}}}

I[09:09:51.946] <-- textDocument/foldingRange(5)
I[09:09:51.947] --> reply:textDocument/foldingRange(5) 1 ms
V[09:09:51.948] >>> {"id":5,"jsonrpc":"2.0","result":[]}

V[09:09:51.971] <<< {"id":6,"jsonrpc":"2.0","method":"textDocument/foldingRange","params":{"textDocument":{"uri":"file:///e%3A/checkout/test.h"}}}

I[09:09:51.971] <-- textDocument/foldingRange(6)
I[09:09:51.973] --> reply:textDocument/foldingRange(6) 1 ms
V[09:09:51.973] >>> {"id":6,"jsonrpc":"2.0","result":[]}

V[09:09:52.175] <<< {"id":7,"jsonrpc":"2.0","method":"textDocument/semanticTokens/full","params":{"textDocument":{"uri":"file:///e%3A/checkout/test.h"}}}

I[09:09:52.175] <-- textDocument/semanticTokens/full(7)
V[09:09:52.175] ASTWorker running SemanticHighlights on version 1 of e:\checkout\test.h
I[09:09:52.175] --> reply:textDocument/semanticTokens/full(7) 0 ms
V[09:09:52.175] >>> {"id":7,"jsonrpc":"2.0","result":{"data":[],"resultId":"1"}}

I[09:09:52.175] --> textDocument/clangd.fileStatus
V[09:09:52.175] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///e:/checkout/test.h"}}

V[09:09:55.842] <<< {"id":8,"jsonrpc":"2.0","method":"textDocument/formatting","params":{"options":{"insertSpaces":true,"tabSize":3},"textDocument":{"uri":"file:///e%3A/checkout/test.h"}}}

I[09:09:55.842] <-- textDocument/formatting(8)
I[09:09:55.846] --> reply:textDocument/formatting(8) 3 ms
V[09:09:55.846] >>> {"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}}}]}

V[09:09:55.872] <<< {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":14,"line":2},"start":{"character":14,"line":2}},"rangeLength":0,"text":"\r\n"},{"range":{"end":{"character":11,"line":2},"start":{"character":10,"line":2}},"rangeLength":1,"text":"c"},{"range":{"end":{"character":11,"line":1},"start":{"character":10,"line":1}},"rangeLength":1,"text":"b"}],"textDocument":{"uri":"file:///e%3A/checkout/test.h","version":2}}}

I[09:09:55.872] <-- textDocument/didChange
I[09:09:55.872] --> textDocument/clangd.fileStatus
V[09:09:55.872] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"file is queued","uri":"file:///e:/checkout/test.h"}}

V[09:09:55.949] <<< {"id":9,"jsonrpc":"2.0","method":"textDocument/inlayHint","params":{"range":{"end":{"character":0,"line":6},"start":{"character":0,"line":0}},"textDocument":{"uri":"file:///e%3A/checkout/test.h"}}}

I[09:09:55.949] <-- textDocument/inlayHint(9)
I[09:09:55.953] ASTWorker building file e:\checkout\test.h version 2 with command inferred from E:\checkout\test.cpp
[E:/checkout/.out/devel-msvc]
"C:\\DevStudio\\Vs2022\\VC\\Tools\\MSVC\\14.38.33130\\bin\\Hostx64\\x64\\cl.exe" --driver-mode=cl /nologo ... -- "e:\\checkout\\test.h"
V[09:09:55.968] Driver produced command: cc1 -cc1 -triple x86_64-pc-windows-msvc19.38.33134 -fsyntax-only ... -x c++ "e:\\checkout\\test.h"
I[09:09:55.968] --> textDocument/clangd.fileStatus
V[09:09:55.968] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"parsing includes, running Update","uri":"file:///e:/checkout/test.h"}}

V[09:09:55.968] Rebuilding invalidated preamble for e:\checkout\test.h version 2 (previous was version 1)
V[09:09:56.065] <<< {"id":10,"jsonrpc":"2.0","method":"textDocument/foldingRange","params":{"textDocument":{"uri":"file:///e%3A/checkout/test.h"}}}

I[09:09:56.065] <-- textDocument/foldingRange(10)
I[09:09:56.066] --> reply:textDocument/foldingRange(10) 0 ms
V[09:09:56.066] >>> {"id":10,"jsonrpc":"2.0","result":[]}

V[09:09:56.165] <<< {"id":11,"jsonrpc":"2.0","method":"textDocument/semanticTokens/full/delta","params":{"previousResultId":"1","textDocument":{"uri":"file:///e%3A/checkout/test.h"}}}

I[09:09:56.165] <-- textDocument/semanticTokens/full/delta(11)
V[09:09:56.215] <<< {"id":12,"jsonrpc":"2.0","method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"file:///e%3A/checkout/test.h"}}}

I[09:09:56.215] <-- textDocument/documentSymbol(12)
V[09:09:56.247] <<< {"id":13,"jsonrpc":"2.0","method":"textDocument/foldingRange","params":{"textDocument":{"uri":"file:///e%3A/checkout/test.h"}}}

I[09:09:56.247] <-- textDocument/foldingRange(13)
I[09:09:56.248] --> reply:textDocument/foldingRange(13) 0 ms
V[09:09:56.248] >>> {"id":13,"jsonrpc":"2.0","result":[]}

V[09:09:56.667] <<< {"jsonrpc":"2.0","method":"$/cancelRequest","params":{"id":9}}

I[09:09:56.667] <-- $/cancelRequest
V[09:09:56.667] <<< {"id":14,"jsonrpc":"2.0","method":"textDocument/inlayHint","params":{"range":{"end":{"character":0,"line":6},"start":{"character":0,"line":0}},"textDocument":{"uri":"file:///e%3A/checkout/test.h"}}}

I[09:09:56.667] <-- textDocument/inlayHint(14)
V[09:09:56.865] <<< {"id":15,"jsonrpc":"2.0","method":"textDocument/documentLink","params":{"textDocument":{"uri":"file:///e%3A/checkout/test.h"}}}

I[09:09:56.865] <-- textDocument/documentLink(15)
I[09:09:57.322] Built preamble of size 10070180 for file e:\checkout\test.h version 2 in 1.35 seconds
I[09:09:57.322] --> workspace/semanticTokens/refresh(3)
V[09:09:57.322] >>> {"id":3,"jsonrpc":"2.0","method":"workspace/semanticTokens/refresh","params":null}

V[09:09:57.324] <<< {"id":3,"jsonrpc":"2.0","result":null}

I[09:09:57.325] <-- reply(3)
V[09:09:57.394] Dropped diagnostic: e:\checkout\__preamble_patch__.h: #line directive with zero argument is a GNU extension
V[09:09:57.395] indexed file AST for e:\checkout\test.h version 2:
  symbol slab: 0 symbols, 128 bytes
  ref slab: 0 symbols, 0 refs, 136 bytes
  relations slab: 0 relations, 24 bytes
V[09:09:57.396] Build dynamic index for main-file symbols with estimated memory usage of 264 bytes
I[09:09:57.396] --> textDocument/publishDiagnostics
V[09:09:57.396] >>> {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"code":"pp_file_not_found","message":"'a.h' file not found","range":{"end":{"character":14,"line":0},"start":{"character":9,"line":0}},"relatedInformation":[],"severity":1,"source":"clang"},{"code":"expected_namespace_name","message":"Expected namespace name","range":{"end":{"character":18,"line":5},"start":{"character":16,"line":5}},"relatedInformation":[],"severity":1,"source":"clang"}],"uri":"file:///e:/checkout/test.h","version":2}}

V[09:09:57.472] indexed file AST for e:\checkout\test.h version 2:
  symbol slab: 0 symbols, 128 bytes
  ref slab: 0 symbols, 0 refs, 136 bytes
  relations slab: 0 relations, 24 bytes
V[09:09:57.472] Build dynamic index for main-file symbols with estimated memory usage of 264 bytes
I[09:09:57.472] --> textDocument/publishDiagnostics
V[09:09:57.472] >>> {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"code":"pp_file_not_found","message":"'a.h' file not found","range":{"end":{"character":14,"line":0},"start":{"character":9,"line":0}},"relatedInformation":[],"severity":1,"source":"clang"},{"code":"expected_namespace_name","message":"Expected namespace name","range":{"end":{"character":18,"line":5},"start":{"character":16,"line":5}},"relatedInformation":[],"severity":1,"source":"clang"}],"uri":"file:///e:/checkout/test.h","version":2}}

I[09:09:57.472] --> reply:textDocument/inlayHint(9) 1523 ms, error: Task was cancelled.
V[09:09:57.472] >>> {"error":{"code":-32800,"message":"Request cancelled"},"id":9,"jsonrpc":"2.0"}

V[09:09:57.472] ASTWorker running SemanticHighlights on version 2 of e:\checkout\test.h
I[09:09:57.472] --> reply:textDocument/semanticTokens/full/delta(11) 1307 ms
V[09:09:57.472] >>> {"id":11,"jsonrpc":"2.0","result":{"edits":[],"resultId":"2"}}

V[09:09:57.472] ASTWorker running DocumentSymbols on version 2 of e:\checkout\test.h
I[09:09:57.472] --> reply:textDocument/documentSymbol(12) 1257 ms
V[09:09:57.472] >>> {"id":12,"jsonrpc":"2.0","result":[]}

V[09:09:57.472] ASTWorker running InlayHints on version 2 of e:\checkout\test.h
I[09:09:57.472] --> reply:textDocument/inlayHint(14) 805 ms
V[09:09:57.472] >>> {"id":14,"jsonrpc":"2.0","result":[]}

V[09:09:57.473] ASTWorker running DocumentLinks on version 2 of e:\checkout\test.h
I[09:09:57.473] --> reply:textDocument/documentLink(15) 607 ms
V[09:09:57.473] >>> {"id":15,"jsonrpc":"2.0","result":[]}

I[09:09:57.473] --> textDocument/clangd.fileStatus
V[09:09:57.473] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///e:/checkout/test.h"}}

[Error - 9:09:57 AM] Request textDocument/inlayHint failed.
[object Object]
V[09:09:57.538] indexed preamble AST for e:\checkout\test.h version 2:
  symbol slab: 13607 symbols, 4139992 bytes
  ref slab: 0 symbols, 0 refs, 136 bytes
  relations slab: 163 relations, 3611 bytes
V[09:09:57.622] Build dynamic index for header symbols with estimated memory usage of 8417084 bytes
V[09:09:58.164] <<< {"id":16,"jsonrpc":"2.0","method":"textDocument/semanticTokens/full/delta","params":{"previousResultId":"2","textDocument":{"uri":"file:///e%3A/checkout/test.h"}}}

I[09:09:58.164] <-- textDocument/semanticTokens/full/delta(16)
V[09:09:58.164] ASTWorker running SemanticHighlights on version 2 of e:\checkout\test.h
I[09:09:58.164] --> reply:textDocument/semanticTokens/full/delta(16) 0 ms
V[09:09:58.164] >>> {"id":16,"jsonrpc":"2.0","result":{"edits":[],"resultId":"3"}}

I[09:09:58.164] --> textDocument/clangd.fileStatus
V[09:09:58.164] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///e:/checkout/test.h"}}

@JVApen
Copy link
Contributor Author

JVApen commented Dec 17, 2024

I can't reproduce this on Linux, even after running the input file through unix2dos (so it has CRLF line endings).

I wouldn't be surprised to see that this is a Windows-only issue

@HighCommander4
Copy link
Contributor

The log you shared doesn't include the didOpen message to show the state of the file before the formatting.

If possible, logs starting at clangd startup are ideal.

@JVApen
Copy link
Contributor Author

JVApen commented Dec 18, 2024

I[09:34:16.811] clangd version 16.0.6
I[09:34:16.812] Features: windows
I[09:34:16.812] PID: 99676
I[09:34:16.812] Working directory: e:\checkout
I[09:34:16.812] argv[0]: E:\clangd.exe
I[09:34:16.812] argv[1]: --log=verbose
I[09:34:16.812] argv[2]: --enable-config
I[09:34:16.812] argv[3]: --header-insertion=iwyu
I[09:34:16.812] argv[4]: --header-insertion-decorators
I[09:34:16.812] argv[5]: --rename-file-limit=0
I[09:34:16.812] argv[6]: --limit-results=1000
I[09:34:16.812] argv[7]: --pch-storage=disk
I[09:34:16.812] argv[8]: --crash-diagnostics-dir=E:\temp
V[09:34:16.830] User config file is C:\Users\JVA\AppData\Local\clangd\config.yaml
I[09:34:16.830] Starting LSP over stdin/stdout
V[09:34:16.831] <<< {"id":0,"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"general":{"markdown":{"parser":"marked","version":"1.1.0"},"positionEncodings":["utf-16"],"regularExpressions":{"engine":"ECMAScript","version":"ES2020"},"staleRequestSupport":{"cancel":true,"retryOnContentModified":["textDocument/semanticTokens/full","textDocument/semanticTokens/range","textDocument/semanticTokens/full/delta"]}},"notebookDocument":{"synchronization":{"dynamicRegistration":true,"executionSummarySupport":true}},"textDocument":{"callHierarchy":{"dynamicRegistration":true},"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"dataSupport":true,"disabledSupport":true,"dynamicRegistration":true,"honorsChangeAnnotations":false,"isPreferredSupport":true,"resolveSupport":{"properties":["edit"]}},"codeLens":{"dynamicRegistration":true},"colorProvider":{"dynamicRegistration":true},"completion":{"completionItem":{"commitCharactersSupport":true,"deprecatedSupport":true,"documentationFormat":["markdown","plaintext"],"insertReplaceSupport":true,"insertTextModeSupport":{"valueSet":[1,2]},"labelDetailsSupport":true,"preselectSupport":true,"resolveSupport":{"properties":["documentation","detail","additionalTextEdits"]},"snippetSupport":true,"tagSupport":{"valueSet":[1]}},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]},"completionList":{"itemDefaults":["commitCharacters","editRange","insertTextFormat","insertTextMode"]},"contextSupport":true,"dynamicRegistration":true,"editsNearCursor":true,"insertTextMode":2},"declaration":{"dynamicRegistration":true,"linkSupport":true},"definition":{"dynamicRegistration":true,"linkSupport":true},"diagnostic":{"dynamicRegistration":true,"relatedDocumentSupport":false},"documentHighlight":{"dynamicRegistration":true},"documentLink":{"dynamicRegistration":true,"tooltipSupport":true},"documentSymbol":{"dynamicRegistration":true,"hierarchicalDocumentSymbolSupport":true,"labelSupport":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"tagSupport":{"valueSet":[1]}},"foldingRange":{"dynamicRegistration":true,"foldingRange":{"collapsedText":false},"foldingRangeKind":{"valueSet":["comment","imports","region"]},"lineFoldingOnly":true,"rangeLimit":5000},"formatting":{"dynamicRegistration":true},"hover":{"contentFormat":["markdown","plaintext"],"dynamicRegistration":true},"implementation":{"dynamicRegistration":true,"linkSupport":true},"inactiveRegionsCapabilities":{"inactiveRegions":true},"inlayHint":{"dynamicRegistration":true,"resolveSupport":{"properties":["tooltip","textEdits","label.tooltip","label.location","label.command"]}},"inlineValue":{"dynamicRegistration":true},"linkedEditingRange":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"publishDiagnostics":{"codeDescriptionSupport":true,"dataSupport":true,"relatedInformation":true,"tagSupport":{"valueSet":[1,2]},"versionSupport":false},"rangeFormatting":{"dynamicRegistration":true},"references":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"honorsChangeAnnotations":true,"prepareSupport":true,"prepareSupportDefaultBehavior":1},"selectionRange":{"dynamicRegistration":true},"semanticTokens":{"augmentsSyntaxTokens":true,"dynamicRegistration":true,"formats":["relative"],"multilineTokenSupport":false,"overlappingTokenSupport":false,"requests":{"full":{"delta":true},"range":true},"serverCancelSupport":true,"tokenModifiers":["declaration","definition","readonly","static","deprecated","abstract","async","modification","documentation","defaultLibrary"],"tokenTypes":["namespace","type","class","enum","interface","struct","typeParameter","parameter","variable","property","enumMember","event","function","method","macro","keyword","modifier","comment","string","number","regexp","operator","decorator"]},"signatureHelp":{"contextSupport":true,"dynamicRegistration":true,"signatureInformation":{"activeParameterSupport":true,"documentationFormat":["markdown","plaintext"],"parameterInformation":{"labelOffsetSupport":true}}},"synchronization":{"didSave":true,"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true},"typeDefinition":{"dynamicRegistration":true,"linkSupport":true},"typeHierarchy":{"dynamicRegistration":true}},"window":{"showDocument":{"support":true},"showMessage":{"messageActionItem":{"additionalPropertiesSupport":true}},"workDoneProgress":true},"workspace":{"applyEdit":true,"codeLens":{"refreshSupport":true},"configuration":true,"diagnostics":{"refreshSupport":true},"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true,"relativePatternSupport":true},"executeCommand":{"dynamicRegistration":true},"fileOperations":{"didCreate":true,"didDelete":true,"didRename":true,"dynamicRegistration":true,"willCreate":true,"willDelete":true,"willRename":true},"inlayHint":{"refreshSupport":true},"inlineValue":{"refreshSupport":true},"semanticTokens":{"refreshSupport":true},"symbol":{"dynamicRegistration":true,"resolveSupport":{"properties":["location.range"]},"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"tagSupport":{"valueSet":[1]}},"workspaceEdit":{"changeAnnotationSupport":{"groupsOnLabel":true},"documentChanges":true,"failureHandling":"textOnlyTransactional","normalizesLineEndings":true,"resourceOperations":["create","rename","delete"]},"workspaceFolders":true}},"clientInfo":{"name":"Visual Studio Code","version":"1.96.0"},"initializationOptions":{"clangdFileStatus":true,"fallbackFlags":[]},"locale":"en-us","processId":52828,"rootPath":"e:\\checkout","rootUri":"file:///e%3A/checkout","trace":"off","workspaceFolders":[{"name":"main","uri":"file:///e%3A/checkout"}]}}

I[09:34:16.831] <-- initialize(0)
I[09:34:16.967] --> reply:initialize(0) 136 ms
V[09:34:16.967] >>> {"id":0,"jsonrpc":"2.0","result":{"capabilities":{"astProvider":true,"callHierarchyProvider":true,"clangdInlayHintsProvider":true,"codeActionProvider":{"codeActionKinds":["quickfix","refactor","info"]},"compilationDatabase":{"automaticReload":true},"completionProvider":{"resolveProvider":false,"triggerCharacters":[".","<",">",":","\"","/","*"]},"declarationProvider":true,"definitionProvider":true,"documentFormattingProvider":true,"documentHighlightProvider":true,"documentLinkProvider":{"resolveProvider":false},"documentOnTypeFormattingProvider":{"firstTriggerCharacter":"\n","moreTriggerCharacter":[]},"documentRangeFormattingProvider":true,"documentSymbolProvider":true,"executeCommandProvider":{"commands":["clangd.applyFix","clangd.applyTweak"]},"foldingRangeProvider":true,"hoverProvider":true,"implementationProvider":true,"inlayHintProvider":true,"memoryUsageProvider":true,"referencesProvider":true,"renameProvider":{"prepareProvider":true},"selectionRangeProvider":true,"semanticTokensProvider":{"full":{"delta":true},"legend":{"tokenModifiers":["declaration","definition","deprecated","deduced","readonly","static","abstract","virtual","dependentName","defaultLibrary","usedAsMutableReference","usedAsMutablePointer","constructorOrDestructor","userDefined","functionScope","classScope","fileScope","globalScope"],"tokenTypes":["variable","variable","parameter","function","method","function","property","variable","class","interface","enum","enumMember","type","type","unknown","namespace","typeParameter","concept","type","macro","modifier","operator","comment"]},"range":false},"signatureHelpProvider":{"triggerCharacters":["(",")","{","}","<",">",","]},"standardTypeHierarchyProvider":true,"textDocumentSync":{"change":2,"openClose":true,"save":true},"typeDefinitionProvider":true,"typeHierarchyProvider":true,"workspaceSymbolProvider":true},"serverInfo":{"name":"clangd","version":"clangd version 16.0.6 windows x86_64-pc-windows-msvc"}}}

V[09:34:17.566] <<< {"jsonrpc":"2.0","method":"initialized","params":{}}

I[09:34:17.566] <-- initialized
I[09:34:17.566] --> client/registerCapability(0)
V[09:34:17.566] >>> {"id":0,"jsonrpc":"2.0","method":"client/registerCapability","params":{"registrations":[{"id":"didChangeWatchedFiles","method":"workspace/didChangeWatchedFiles","registerOptions":{"watchers":[{"globPattern":"**/*.c"},{"globPattern":"**/*.cc"},{"globPattern":"**/*.cpp"},{"globPattern":"**/*.c++"},{"globPattern":"**/*.cxx"},{"globPattern":"**/*.h"},{"globPattern":"**/*.hh"},{"globPattern":"**/*.hpp"},{"globPattern":"**/*.h++"},{"globPattern":"**/*.hxx"},{"globPattern":"**/*.m"},{"globPattern":"**/*.mm"},{"globPattern":"**/*.i"},{"globPattern":"**/*.ii"},{"globPattern":"**/*.mi"},{"globPattern":"**/*.mmi"},{"globPattern":"**/*.def"},{"globPattern":"**/*.inc"}]}}]}}

V[09:34:18.017] <<< {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"cpp","text":"#include \"a.h\"\r\n#include \"c.h\"\r\n#include \"b.h\"\r\n\r\nusing namespace NS;\r\n","uri":"file:///e%3A/checkout/test.cpp","version":1}}}

I[09:34:18.017] <-- textDocument/didOpen
V[09:34:18.058] config note at e:\checkout\.clangd:2:0: Parsing config fragment
V[09:34:18.058] config note at e:\checkout\.clangd:1:0: Parsed 1 fragments from file
V[09:34:18.058] Config fragment: compiling e:\checkout\.clangd:2 -> 0x0000019812FBAB30 (trusted=false)
I[09:34:18.061] --> textDocument/publishDiagnostics
V[09:34:18.061] >>> {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[],"uri":"file:///e:/checkout/.clangd"}}

V[09:34:18.251] <<< {"id":0,"jsonrpc":"2.0","result":null}

I[09:34:18.251] <-- reply(0)
V[09:34:18.258] <<< {"jsonrpc":"2.0","method":"$/setTrace","params":{"value":"off"}}

I[09:34:18.258] <-- $/setTrace
I[09:34:18.258] unhandled notification $/setTrace
V[09:34:18.321] <<< {"jsonrpc":"2.0","method":"$/setTrace","params":{"value":"off"}}

I[09:34:18.321] <-- $/setTrace
I[09:34:18.321] unhandled notification $/setTrace
V[09:34:18.417] <<< {"id":1,"jsonrpc":"2.0","method":"textDocument/documentLink","params":{"textDocument":{"uri":"file:///e%3A/checkout/test.cpp"}}}

I[09:34:18.417] <-- textDocument/documentLink(1)
V[09:34:18.430] <<< {"id":2,"jsonrpc":"2.0","method":"textDocument/inlayHint","params":{"range":{"end":{"character":0,"line":5},"start":{"character":0,"line":0}},"textDocument":{"uri":"file:///e%3A/checkout/test.cpp"}}}

I[09:34:18.430] <-- textDocument/inlayHint(2)
V[09:34:18.452] <<< {"id":3,"jsonrpc":"2.0","method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"file:///e%3A/checkout/test.cpp"}}}

I[09:34:18.453] <-- textDocument/documentSymbol(3)
V[09:34:18.453] <<< {"id":4,"jsonrpc":"2.0","method":"textDocument/foldingRange","params":{"textDocument":{"uri":"file:///e%3A/checkout/test.cpp"}}}

I[09:34:18.453] <-- textDocument/foldingRange(4)
V[09:34:18.454] <<< {"jsonrpc":"2.0","method":"$/cancelRequest","params":{"id":1}}

I[09:34:18.454] <-- $/cancelRequest
V[09:34:18.454] <<< {"id":5,"jsonrpc":"2.0","method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"file:///e%3A/checkout/test.cpp"}}}

I[09:34:18.454] <-- textDocument/documentSymbol(5)
V[09:34:18.455] <<< {"id":6,"jsonrpc":"2.0","method":"textDocument/documentLink","params":{"textDocument":{"uri":"file:///e%3A/checkout/test.cpp"}}}

I[09:34:18.455] <-- textDocument/documentLink(6)
I[09:34:18.496] --> reply:textDocument/foldingRange(4) 42 ms
V[09:34:18.499] >>> {"id":4,"jsonrpc":"2.0","result":[]}

V[09:34:18.577] <<< {"id":7,"jsonrpc":"2.0","method":"textDocument/semanticTokens/full","params":{"textDocument":{"uri":"file:///e%3A/checkout/test.cpp"}}}

I[09:34:18.577] <-- textDocument/semanticTokens/full(7)
V[09:34:18.687] <<< {"jsonrpc":"2.0","method":"$/cancelRequest","params":{"id":5}}

I[09:34:18.687] <-- $/cancelRequest
V[09:34:18.688] <<< {"jsonrpc":"2.0","method":"$/cancelRequest","params":{"id":3}}

I[09:34:18.688] <-- $/cancelRequest
V[09:34:18.689] <<< {"id":8,"jsonrpc":"2.0","method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"file:///e%3A/checkout/test.cpp"}}}

I[09:34:18.689] <-- textDocument/documentSymbol(8)
V[09:34:18.690] <<< {"jsonrpc":"2.0","method":"$/cancelRequest","params":{"id":6}}

I[09:34:18.690] <-- $/cancelRequest
V[09:34:18.788] <<< {"id":9,"jsonrpc":"2.0","method":"textDocument/documentLink","params":{"textDocument":{"uri":"file:///e%3A/checkout/test.cpp"}}}

I[09:34:18.788] <-- textDocument/documentLink(9)
V[09:34:19.208] <<< {"id":10,"jsonrpc":"2.0","method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"file:///e%3A/checkout/test.cpp"}}}

I[09:34:19.208] <-- textDocument/documentSymbol(10)
V[09:34:19.208] <<< {"id":11,"jsonrpc":"2.0","method":"textDocument/foldingRange","params":{"textDocument":{"uri":"file:///e%3A/checkout/test.cpp"}}}

I[09:34:19.208] <-- textDocument/foldingRange(11)
I[09:34:19.215] --> reply:textDocument/foldingRange(11) 6 ms
V[09:34:19.215] >>> {"id":11,"jsonrpc":"2.0","result":[]}

I[09:34:20.216] Loaded compilation database from e:\checkout\compile_commands.json
V[09:34:20.238] Broadcasting compilation database from e:\checkout
I[09:34:20.240] ASTWorker building file e:\checkout\test.cpp version 1 with command 
[E:/checkout/.out/devel-msvc]
"C:\\DevStudio\\Vs2022\\VC\\Tools\\MSVC\\14.38.33130\\bin\\Hostx64\\x64\\cl.exe" --driver-mode=cl /nologo ... -- "e:\\checkout\\test.cpp"
V[09:34:20.252] config note at E:\checkout\.clangd:2:0: Parsing config fragment
V[09:34:20.252] config note at E:\checkout\.clangd:1:0: Parsed 1 fragments from file
V[09:34:20.252] Config fragment: compiling E:\checkout\.clangd:2 -> 0x0000019848C48BA0 (trusted=false)
I[09:34:20.253] --> textDocument/publishDiagnostics
V[09:34:20.253] >>> {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[],"uri":"file:///E:/checkout/.clangd"}}

V[09:34:20.308] Driver produced command: cc1 -cc1 -triple x86_64-pc-windows-msvc19.38.33134 -fsyntax-only ... -x c++ "e:\\checkout\\test.cpp"
I[09:34:20.309] --> textDocument/clangd.fileStatus
V[09:34:20.309] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"parsing includes, running Update","uri":"file:///e:/checkout/test.cpp"}}

V[09:34:20.309] Building first preamble for e:\checkout\test.cpp version 1
I[09:34:24.645] Loaded compilation database from E:\checkout\.out\devel-msvc\compile_commands.json
I[09:34:25.963] Built preamble of size 10070296 for file e:\checkout\test.cpp version 1 in 5.65 seconds
I[09:34:25.965] --> workspace/semanticTokens/refresh(1)
V[09:34:25.965] >>> {"id":1,"jsonrpc":"2.0","method":"workspace/semanticTokens/refresh","params":null}

V[09:34:25.967] <<< {"id":1,"jsonrpc":"2.0","result":null}

I[09:34:25.967] <-- reply(1)
V[09:34:26.097] indexed file AST for e:\checkout\test.cpp version 1:
  symbol slab: 0 symbols, 128 bytes
  ref slab: 0 symbols, 0 refs, 136 bytes
  relations slab: 0 relations, 24 bytes
V[09:34:26.097] Build dynamic index for main-file symbols with estimated memory usage of 264 bytes
I[09:34:26.098] --> textDocument/publishDiagnostics
V[09:34:26.098] >>> {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"code":"pp_file_not_found","message":"'a.h' file not found","range":{"end":{"character":14,"line":0},"start":{"character":9,"line":0}},"relatedInformation":[],"severity":1,"source":"clang"},{"code":"expected_namespace_name","message":"Expected namespace name","range":{"end":{"character":18,"line":4},"start":{"character":16,"line":4}},"relatedInformation":[],"severity":1,"source":"clang"},{"code":"llvm-include-order","codeDescription":{"href":"https://clang.llvm.org/extra/clang-tidy/checks/llvm/include-order.html"},"message":"#includes are not sorted properly (fix available)","range":{"end":{"character":1,"line":1},"start":{"character":0,"line":1}},"relatedInformation":[],"severity":2,"source":"clang-tidy"}],"uri":"file:///e:/checkout/test.cpp","version":1}}

I[09:34:26.098] --> reply:textDocument/documentLink(1) 7680 ms, error: Task was cancelled.
V[09:34:26.098] >>> {"error":{"code":-32800,"message":"Request cancelled"},"id":1,"jsonrpc":"2.0"}

V[09:34:26.098] ASTWorker running InlayHints on version 1 of e:\checkout\test.cpp
I[09:34:26.098] --> reply:textDocument/inlayHint(2) 7667 ms
V[09:34:26.098] >>> {"id":2,"jsonrpc":"2.0","result":[]}

I[09:34:26.098] --> reply:textDocument/documentSymbol(3) 7645 ms, error: Task was cancelled.
V[09:34:26.098] >>> {"error":{"code":-32800,"message":"Request cancelled"},"id":3,"jsonrpc":"2.0"}

I[09:34:26.098] --> reply:textDocument/documentSymbol(5) 7643 ms, error: Task was cancelled.
V[09:34:26.098] >>> {"error":{"code":-32800,"message":"Request cancelled"},"id":5,"jsonrpc":"2.0"}

I[09:34:26.098] --> reply:textDocument/documentLink(6) 7642 ms, error: Task was cancelled.
V[09:34:26.098] >>> {"error":{"code":-32800,"message":"Request cancelled"},"id":6,"jsonrpc":"2.0"}

V[09:34:26.098] ASTWorker running SemanticHighlights on version 1 of e:\checkout\test.cpp
I[09:34:26.098] --> reply:textDocument/semanticTokens/full(7) 7521 ms
V[09:34:26.098] >>> {"id":7,"jsonrpc":"2.0","result":{"data":[],"resultId":"1"}}

V[09:34:26.098] ASTWorker running DocumentSymbols on version 1 of e:\checkout\test.cpp
I[09:34:26.098] --> reply:textDocument/documentSymbol(8) 7408 ms
V[09:34:26.098] >>> {"id":8,"jsonrpc":"2.0","result":[]}

V[09:34:26.098] ASTWorker running DocumentLinks on version 1 of e:\checkout\test.cpp
I[09:34:26.098] --> reply:textDocument/documentLink(9) 7309 ms
V[09:34:26.098] >>> {"id":9,"jsonrpc":"2.0","result":[]}

V[09:34:26.098] ASTWorker running DocumentSymbols on version 1 of e:\checkout\test.cpp
I[09:34:26.098] --> reply:textDocument/documentSymbol(10) 6889 ms
V[09:34:26.098] >>> {"id":10,"jsonrpc":"2.0","result":[]}

I[09:34:26.098] --> textDocument/clangd.fileStatus
V[09:34:26.098] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///e:/checkout/test.cpp"}}

[Error - 9:34:26 AM] Request textDocument/documentLink failed.
[object Object]
V[09:34:26.174] indexed preamble AST for e:\checkout\test.cpp version 1:
  symbol slab: 13607 symbols, 4139992 bytes
  ref slab: 0 symbols, 0 refs, 136 bytes
  relations slab: 163 relations, 3611 bytes
[Error - 9:34:26 AM] Request textDocument/documentSymbol failed.
[object Object]
[Error - 9:34:26 AM] Request textDocument/documentSymbol failed.
[object Object]
[Error - 9:34:26 AM] Request textDocument/documentLink failed.
[object Object]
V[09:34:26.468] Build dynamic index for header symbols with estimated memory usage of 8430076 bytes
I[09:34:27.961] --> window/workDoneProgress/create(2)
V[09:34:27.961] >>> {"id":2,"jsonrpc":"2.0","method":"window/workDoneProgress/create","params":{"token":"backgroundIndexProgress"}}

I[09:34:27.961] Enqueueing 34251 commands for indexing
V[09:34:28.036] <<< {"id":2,"jsonrpc":"2.0","result":null}

I[09:34:28.036] <-- reply(2)
I[09:34:28.036] --> $/progress
V[09:34:28.036] >>> {"jsonrpc":"2.0","method":"$/progress","params":{"token":"backgroundIndexProgress","value":{"kind":"begin","percentage":0,"title":"indexing"}}}

I[09:34:28.036] --> $/progress
V[09:34:28.036] >>> {"jsonrpc":"2.0","method":"$/progress","params":{"token":"backgroundIndexProgress","value":{"kind":"report","message":"0/1","percentage":0}}}

V[09:34:28.457] <<< {"id":12,"jsonrpc":"2.0","method":"textDocument/semanticTokens/full/delta","params":{"previousResultId":"1","textDocument":{"uri":"file:///e%3A/checkout/test.cpp"}}}

I[09:34:28.457] <-- textDocument/semanticTokens/full/delta(12)
V[09:34:28.457] ASTWorker running SemanticHighlights on version 1 of e:\checkout\test.cpp
I[09:34:28.457] --> reply:textDocument/semanticTokens/full/delta(12) 0 ms
V[09:34:28.457] >>> {"id":12,"jsonrpc":"2.0","result":{"edits":[],"resultId":"2"}}

I[09:34:28.457] --> textDocument/clangd.fileStatus
V[09:34:28.457] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///e:/checkout/test.cpp"}}

I[09:34:31.104] --> $/progress
V[09:34:31.104] >>> {"jsonrpc":"2.0","method":"$/progress","params":{"token":"backgroundIndexProgress","value":{"kind":"report","message":"0/1","percentage":0}}}

I[09:34:31.104] --> $/progress
V[09:34:31.104] >>> {"jsonrpc":"2.0","method":"$/progress","params":{"token":"backgroundIndexProgress","value":{"kind":"end"}}}

V[09:34:39.552] <<< {"id":13,"jsonrpc":"2.0","method":"textDocument/formatting","params":{"options":{"insertSpaces":true,"tabSize":3},"textDocument":{"uri":"file:///e%3A/checkout/test.cpp"}}}

I[09:34:39.552] <-- textDocument/formatting(13)
V[09:34:39.553] config note at e:\checkout\.clangd:2:0: Parsing config fragment
V[09:34:39.554] config note at e:\checkout\.clangd:1:0: Parsed 1 fragments from file
V[09:34:39.554] Config fragment: compiling e:\checkout\.clangd:2 -> 0x0000019821308120 (trusted=false)
I[09:34:39.556] --> textDocument/publishDiagnostics
V[09:34:39.556] >>> {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[],"uri":"file:///e:/checkout/.clangd"}}

I[09:34:39.562] --> reply:textDocument/formatting(13) 9 ms
V[09:34:39.562] >>> {"id":13,"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}}}]}

V[09:34:39.577] <<< {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":14,"line":2},"start":{"character":14,"line":2}},"rangeLength":0,"text":"\r\n"},{"range":{"end":{"character":11,"line":2},"start":{"character":10,"line":2}},"rangeLength":1,"text":"c"},{"range":{"end":{"character":11,"line":1},"start":{"character":10,"line":1}},"rangeLength":1,"text":"b"}],"textDocument":{"uri":"file:///e%3A/checkout/test.cpp","version":2}}}

I[09:34:39.577] <-- textDocument/didChange
I[09:34:39.577] --> textDocument/clangd.fileStatus
V[09:34:39.577] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"file is queued","uri":"file:///e:/checkout/test.cpp"}}

I[09:34:39.742] ASTWorker building file e:\checkout\test.cpp version 2 with command 
[E:/checkout/.out/devel-msvc]
"C:\\DevStudio\\Vs2022\\VC\\Tools\\MSVC\\14.38.33130\\bin\\Hostx64\\x64\\cl.exe" --driver-mode=cl /nologo ... -- "e:\\checkout\\test.cpp"
V[09:34:39.772] Driver produced command: cc1 -cc1 -triple x86_64-pc-windows-msvc19.38.33134 -fsyntax-only ... -x c++ "e:\\checkout\\test.cpp"
I[09:34:39.772] --> textDocument/clangd.fileStatus
V[09:34:39.772] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"parsing includes, running Update","uri":"file:///e:/checkout/test.cpp"}}

V[09:34:39.773] Rebuilding invalidated preamble for e:\checkout\test.cpp version 2 (previous was version 1)
V[09:34:39.943] <<< {"id":14,"jsonrpc":"2.0","method":"textDocument/foldingRange","params":{"textDocument":{"uri":"file:///e%3A/checkout/test.cpp"}}}

I[09:34:39.943] <-- textDocument/foldingRange(14)
V[09:34:39.943] <<< {"id":15,"jsonrpc":"2.0","method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"file:///e%3A/checkout/test.cpp"}}}

I[09:34:39.943] <-- textDocument/documentSymbol(15)
I[09:34:39.944] --> reply:textDocument/foldingRange(14) 1 ms
V[09:34:39.944] >>> {"id":14,"jsonrpc":"2.0","result":[]}

V[09:34:40.202] <<< {"id":16,"jsonrpc":"2.0","method":"textDocument/inlayHint","params":{"range":{"end":{"character":0,"line":6},"start":{"character":0,"line":0}},"textDocument":{"uri":"file:///e%3A/checkout/test.cpp"}}}

I[09:34:40.202] <-- textDocument/inlayHint(16)
V[09:34:40.399] <<< {"jsonrpc":"2.0","method":"$/cancelRequest","params":{"id":16}}

I[09:34:40.399] <-- $/cancelRequest
V[09:34:40.399] <<< {"id":17,"jsonrpc":"2.0","method":"textDocument/inlayHint","params":{"range":{"end":{"character":0,"line":6},"start":{"character":0,"line":0}},"textDocument":{"uri":"file:///e%3A/checkout/test.cpp"}}}

I[09:34:40.399] <-- textDocument/inlayHint(17)
I[09:34:41.308] Built preamble of size 10070300 for file e:\checkout\test.cpp version 2 in 1.54 seconds
I[09:34:41.309] --> workspace/semanticTokens/refresh(3)
V[09:34:41.309] >>> {"id":3,"jsonrpc":"2.0","method":"workspace/semanticTokens/refresh","params":null}

V[09:34:41.311] <<< {"id":3,"jsonrpc":"2.0","result":null}

I[09:34:41.311] <-- reply(3)
V[09:34:41.312] <<< {"id":18,"jsonrpc":"2.0","method":"textDocument/semanticTokens/full/delta","params":{"previousResultId":"2","textDocument":{"uri":"file:///e%3A/checkout/test.cpp"}}}

I[09:34:41.312] <-- textDocument/semanticTokens/full/delta(18)
V[09:34:41.398] Dropped diagnostic: e:\checkout\__preamble_patch__.h: #line directive with zero argument is a GNU extension
V[09:34:41.400] indexed file AST for e:\checkout\test.cpp version 2:
  symbol slab: 0 symbols, 128 bytes
  ref slab: 0 symbols, 0 refs, 136 bytes
  relations slab: 0 relations, 24 bytes
V[09:34:41.400] Build dynamic index for main-file symbols with estimated memory usage of 264 bytes
I[09:34:41.400] --> textDocument/publishDiagnostics
V[09:34:41.400] >>> {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"code":"pp_file_not_found","message":"'a.h' file not found","range":{"end":{"character":14,"line":0},"start":{"character":9,"line":0}},"relatedInformation":[],"severity":1,"source":"clang"},{"code":"expected_namespace_name","message":"Expected namespace name","range":{"end":{"character":18,"line":5},"start":{"character":16,"line":5}},"relatedInformation":[],"severity":1,"source":"clang"}],"uri":"file:///e:/checkout/test.cpp","version":2}}

V[09:34:41.482] indexed file AST for e:\checkout\test.cpp version 2:
  symbol slab: 0 symbols, 128 bytes
  ref slab: 0 symbols, 0 refs, 136 bytes
  relations slab: 0 relations, 24 bytes
V[09:34:41.482] Build dynamic index for main-file symbols with estimated memory usage of 264 bytes
I[09:34:41.483] --> textDocument/publishDiagnostics
V[09:34:41.483] >>> {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"code":"pp_file_not_found","message":"'a.h' file not found","range":{"end":{"character":14,"line":0},"start":{"character":9,"line":0}},"relatedInformation":[],"severity":1,"source":"clang"},{"code":"expected_namespace_name","message":"Expected namespace name","range":{"end":{"character":18,"line":5},"start":{"character":16,"line":5}},"relatedInformation":[],"severity":1,"source":"clang"}],"uri":"file:///e:/checkout/test.cpp","version":2}}

V[09:34:41.483] ASTWorker running DocumentSymbols on version 2 of e:\checkout\test.cpp
I[09:34:41.483] --> reply:textDocument/documentSymbol(15) 1539 ms
V[09:34:41.483] >>> {"id":15,"jsonrpc":"2.0","result":[]}

I[09:34:41.483] --> reply:textDocument/inlayHint(16) 1280 ms, error: Task was cancelled.
V[09:34:41.483] >>> {"error":{"code":-32800,"message":"Request cancelled"},"id":16,"jsonrpc":"2.0"}

V[09:34:41.483] ASTWorker running InlayHints on version 2 of e:\checkout\test.cpp
I[09:34:41.483] --> reply:textDocument/inlayHint(17) 1083 ms
V[09:34:41.483] >>> {"id":17,"jsonrpc":"2.0","result":[]}

V[09:34:41.483] ASTWorker running SemanticHighlights on version 2 of e:\checkout\test.cpp
I[09:34:41.483] --> reply:textDocument/semanticTokens/full/delta(18) 170 ms
V[09:34:41.483] >>> {"id":18,"jsonrpc":"2.0","result":{"edits":[],"resultId":"3"}}

I[09:34:41.483] --> textDocument/clangd.fileStatus
V[09:34:41.483] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///e:/checkout/test.cpp"}}

[Error - 9:34:41 AM] Request textDocument/inlayHint failed.
[object Object]
V[09:34:41.585] indexed preamble AST for e:\checkout\test.cpp version 2:
  symbol slab: 13607 symbols, 4139992 bytes
  ref slab: 0 symbols, 0 refs, 136 bytes
  relations slab: 163 relations, 3611 bytes
V[09:34:41.685] Build dynamic index for header symbols with estimated memory usage of 8429372 bytes
V[09:34:43.585] <<< {"id":19,"jsonrpc":"2.0","method":"textDocument/documentLink","params":{"textDocument":{"uri":"file:///e%3A/checkout/test.cpp"}}}

I[09:34:43.585] <-- textDocument/documentLink(19)
V[09:34:43.585] ASTWorker running DocumentLinks on version 2 of e:\checkout\test.cpp
I[09:34:43.585] --> reply:textDocument/documentLink(19) 0 ms
V[09:34:43.585] >>> {"id":19,"jsonrpc":"2.0","result":[]}

I[09:34:43.585] --> textDocument/clangd.fileStatus
V[09:34:43.585] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///e:/checkout/test.cpp"}}

V[09:34:43.681] <<< {"id":20,"jsonrpc":"2.0","method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"file:///e%3A/checkout/test.cpp"}}}

I[09:34:43.681] <-- textDocument/documentSymbol(20)
V[09:34:43.681] ASTWorker running DocumentSymbols on version 2 of e:\checkout\test.cpp
I[09:34:43.681] --> reply:textDocument/documentSymbol(20) 0 ms
V[09:34:43.681] >>> {"id":20,"jsonrpc":"2.0","result":[]}

I[09:34:43.681] --> textDocument/clangd.fileStatus
V[09:34:43.681] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///e:/checkout/test.cpp"}}

@HighCommander4
Copy link
Contributor

HighCommander4 commented Dec 20, 2024

Thanks; I am able to reproduce the issue on Linux now, with an input file containing \r\n line endings.

Looking at the server's response to textDocument/formatting:

{
  "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 \r on the line, but not the \n.

This certainly seems a bit odd (why include the \r but not the \n instead of both, or neither?), and might perhaps be interesting to investigate more deeply in clang-format internals... but on the other hand, the replacement text is consistent with this: it includes an \r, and not an \n at the end.

Naively, it seems to me that replacing a character range ending with \r with a new character sequence that also ends with \r should work? i.e. it seems to me that vscode is messing up this replacement somehow, inventing an additional \r\n pair from thin air.

@HighCommander4
Copy link
Contributor

HighCommander4 commented Dec 20, 2024

I couldn't find the code in the extension that applies these changes,

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 textDocument/formatting feature, that happens around here in the vscode-languageclient source, but what that code does is not very interesting: it just converts the edits from the LSP representation to the vscode extension API representation.

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 registerDocumentFormattingEditProvider API called here, and see how the implementation uses the formatting provider that's passed in.

@JVApen
Copy link
Contributor Author

JVApen commented Dec 20, 2024

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 #include and shuffles it around. It happens to be the last character as it splits on \n

@JVApen
Copy link
Contributor Author

JVApen commented Dec 20, 2024

I've logged an issue with VS Code, we'll see when they fix it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants