[clang] [clang-tools-extra] [clangd] Add InsertReplaceEdit for code completion (PR #187623)

via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 29 05:04:44 PDT 2026


argothiel wrote:

@timon-ul
I referred to it in this comment: https://github.com/llvm/llvm-project/pull/187623#issuecomment-4095094229.

VS Code client is fine, it supports both versions; the gap is in the vscode-clangd plugin, and only in the `serverCompletionRanking` workaround path. I thought of fixing that first, but it's not a bug per se, more like a missing functionality needed only if this PR gets merged. So yeah, they need to be coordinated, and I'll happily deliver a fix if this PR is closer to merging. For testing locally, you can set `"clangd.serverCompletionRanking": false` for now. I haven't checked other editors.


As for lexing, I think it's the right place to keep it in the lexer, even if it's less convenient to review. We could duplicate the lexing logic in clangd, but I think the proper architecture would be to coordinate it with the lexer code. It's also not risky, because it's adding a new method, mirroring the already existing methods (`MeasureTokenLength`, `getRawToken`), not changing any of its logic. The best would be to get someone from the lexing to take a look and advise. Note that lexing actually depends on the language mode; for example, LangOptions-driven lexing takes into account whether `$` is a valid identifier character, or which Unicode codepoints are valid, and this entire logic would have to be duplicated if we wanted to do it right.

https://github.com/llvm/llvm-project/pull/187623


More information about the cfe-commits mailing list