[clang] [clang-tools-extra] [clangd] Add InsertReplaceEdit for code completion (PR #187623)
via cfe-commits
cfe-commits at lists.llvm.org
Fri May 1 13:18:17 PDT 2026
timon-ul wrote:
> Regarding the findTokenAfterCompletionPoint method, I considered it, but the semantics is slightly different, even apart from the Unicode handling.
Looking at how the `nextToken` is [used](https://searchfox.org/llvm/source/clang-tools-extra/clangd/CodeComplete.cpp#601) I feel like the 2 main issues you are touching on are not particularly wanted behaviour, but more like accepted behaviour? It seems to be only used to find out if it is followed by a template argument list or a regular argument list. So no functionality would be lost by adapting that function to yours instead (again, so we do not run the lexer twice for the follow up token). Unless I am missing something.
> Note, that the completed text must be the same for insert and replace
Ah right, this could leave to awkward behaviour in the insert mode, where you do not get an argument list because you happen to have one later that just happens to fit. But this is a rather rare occasion and I think at least personally the replace mode is anyways more useful so I am more convinced to go this route (quite frankly I do not see when insert mode is superior anyway). As you said though, a follow up PR is probably the right place for this.
https://github.com/llvm/llvm-project/pull/187623
More information about the cfe-commits
mailing list