Hi, Pecan, I did some test, I tred to use different clangd from winlibs, I tried to used to use the online visual studio code.
It looks like clangd does not have this issue. so I guess the issue is inside the clangd_plugin code. clangd_plugin rev66 about one months ago works OK.
I compared rev67 and rev66, especially the log file. By comparing the logs from clangd_plugin rev66 and rev67, I noticed some difference.
It looks like the textDocument/didOpen method is different. In rev67, it just send an empty string.
Here is the log of rev66, it looks good. (Note I cut down the source file path, because it was a bit long)
20:25:11.290 <<< Content-Length: 614
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"cpp","text":"\r\n\r\n\r\n\r\nint abc;\r\n\r\n\r\nint main()\r\n{\r\n abc = 3;\r\n return 0;\r\n}\r\n\r\n\r\n#include <string>\r\n\r\n\r\nstd::string Utf8ToGbk(const std::string& strUtf8);\r\n\r\nstd::string Utf8ToGbk(const std::string& strUtf8)\r\n{\r\n // 上面的函数\r\n // return unicodeString.ToStdString(); 默认使用当前操作系统的编码格式,Windows通常为GB2312\r\n return strUtf8;\r\n}\r\n\r\n\r\n\r\n","uri":"file:///D:/project/test5-readtext/a.cpp","version":0}}}
In rev67, the log looks wrong, because an empty string is passed.
20:27:05.074 <<< Content-Length: 185
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"cpp","text":"","uri":"file:///D:/test5-readtext/a.cpp","version":0}}}
You can see, the "text":"". So, it just send the empty string to the clangd?