Say I have a piece of code like foo.bar()
, but I realize I need to change it to foo.unwrap().bar()
. If I first move to the position after the dot, and start typing unwrap
, I'll reach a state like foo.unw^bar()
(where ^
denotes my cursor position). At this point, if I use company-complete-selection
to complete unwrap
, it turns into foo.unwrap()
, i.e. the bar
gets eaten.
Note that this "eating" gets blocked by punctuation, e.g. If I have foo..bar()
, and position myself between the two dots, type unw
and then complete, I get foo.unwrap^.bar()
, which is what I want (^
is again cursor position).
I'm using doom emacs, writing rust code with lsp-mode and rustic-mode (and company-mode). I actually don't know if this is an issue with company, or if it's rust-specific. Maybe the rust language server (rust-analyzer) is providing company with "completions" that include eating the following word?
I haven't tested whether this type of issue applies
The variable lsp-completion-default-behaviour
controls this. You can change it to :insert
instead of :replace
to get that behaviour.