Subject: bug#72765: Eglot + Clangd + Company + non-empty suffix = duplicate text

From: Dmitry Gutov <[email-masked]>
Date: Fri, 23 Aug 2024 02:07:59 +0300

Here's an example I came upon when testing:

test.c
```
int foo_bar_1;
int foo_bar_2;

int main() {foo_bar|456

```

Point is at |.

If you use completion-at-point, *Completions* buffer pops up, you choose 
one of the options with M-down and M-RET, "_1" is inserted. Good.

But if you use Company, type "_" (or backspace and re-add "r") - a popup 
comes up with "foo_bar_1" and "foo_bar_2", you choose one of the 
options, and the text becomes "foo_bar_1456456", suffix is duplicated.

This only happens with Clang, out of the servers I've tested.

You need a fairly recent Company to reproduce (from master), the 
previous versions simply didn't support completion in the middle of a 
symbol.

To add something that completion-at-point trips over, though: when 
"foo_bar_2" (existing var name) is already inserted, move point to the 
middle of it and press C-M-i:

```
   foo_|bar_2
```

will turn to

```
   foo_bar_2bar_2|
```