[PATCH] D133299: [clangd] Fix LineFoldingOnly flag is not propagated correctly to ClangdServer.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 5 06:05:20 PDT 2022
hokein created this revision.
hokein added reviewers: usaxena95, kadircet.
Herald added a subscriber: arphaman.
Herald added a project: All.
hokein requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.
The Opts.LineFoldingOnly must be set before the clangdServer
construction, otherwise this flag is always false when using clangd in VSCode.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D133299
Files:
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/test/folding-range.test
Index: clang-tools-extra/clangd/test/folding-range.test
===================================================================
--- /dev/null
+++ clang-tools-extra/clangd/test/folding-range.test
@@ -0,0 +1,24 @@
+# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
+void f() {
+
+}
+---
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{"textDocument": {"foldingRange": {"lineFoldingOnly": true}}},"trace":"off"}}
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"cpp","text":"void f() {\n\n}\n","uri":"test:///foo.cpp","version":1}}}
+---
+{"id":1,"jsonrpc":"2.0","method":"textDocument/foldingRange","params":{"textDocument":{"uri":"test:///foo.cpp"}}}
+# CHECK: "id": 1,
+# CHECK-NEXT: "jsonrpc": "2.0",
+# CHECK-NEXT: "result": [
+# CHECK-NEXT: {
+# CHECK-NEXT: "endLine": 1,
+# CHECK-NEXT: "kind": "region",
+# CHECK-NEXT: "startCharacter": 10,
+# CHECK-NEXT: "startLine": 0
+# CHECK-NEXT: }
+# CHECK-NEXT: ]
+---
+{"jsonrpc":"2.0","id":5,"method":"shutdown"}
+---
+{"jsonrpc":"2.0","method":"exit"}
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===================================================================
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -459,6 +459,9 @@
"no longer supported. Migrate to standard semanticTokens request");
}
+ // Must be initialized before creating a ClangdServer object!
+ Opts.LineFoldingOnly = Params.capabilities.LineFoldingOnly;
+
if (Params.rootUri && *Params.rootUri)
Opts.WorkspaceRoot = std::string(Params.rootUri->file());
else if (Params.rootPath && !Params.rootPath->empty())
@@ -514,7 +517,6 @@
Params.capabilities.HierarchicalDocumentSymbol;
SupportFileStatus = Params.initializationOptions.FileStatus;
HoverContentFormat = Params.capabilities.HoverContentFormat;
- Opts.LineFoldingOnly = Params.capabilities.LineFoldingOnly;
SupportsOffsetsInSignatureHelp = Params.capabilities.OffsetsInSignatureHelp;
if (Params.capabilities.WorkDoneProgress)
BackgroundIndexProgressState = BackgroundIndexProgress::Empty;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133299.457960.patch
Type: text/x-patch
Size: 2217 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220905/d69e1483/attachment.bin>
More information about the cfe-commits
mailing list