lsp-mode
lsp-mode copied to clipboard
During some completions, placeholder text does not get replaced.
Thank you for the bug report
- [X] I am using the latest version of
lsp-mode
related packages. - [X] I checked FAQ and Troubleshooting sections
- [X] You may also try reproduce the issue using clean environment using the following command:
M-x lsp-start-plain
Bug description
In a buffer in c-mode
with the following content (with point after retu
), pressing enter completes to return expression;
.
int main(int argc, char** argv) {
retu
}
Point is now at the beginning of expression
, but starting to type doesn't replace the placeholder text; instead it inserts new text before it.
Steps to reproduce
- Run
emacs -q -l /tmp/lsp-start-plain.el
- Create a buffer in c-mode with the contents
int main(int argc, char**argv) {
}
- On the second line, type
retu
. - Wait for the completion suggestion to come up and type
RET
. - Start typing an expression.
Expected behavior
I expect that the placeholder text expression
is replaced by whatever I start typing, but instead what I type is inserted before expression
.
Which Language Server did you use?
clangd
OS
MacOS
Error callstack
No response
Anything else?
Some completions do not have this issue. For example, in
int foo(int bar) { return bar; }
int main(int argc, char** argv) {
return foo
}
I can press enter when point is after foo
to complete to foo(int bar)
, and in that case typing replaces the placeholder int bar
as expected.
This seems to be a problem with yasnippet
instead. You can try
(defun test-a ()
(interactive)
(yas-expand-snippet "return ${0:expression};"))
(defun test-b ()
(interactive)
(yas-expand-snippet "return ${1:expression};"))
Using M-x test-a
will behave as you described, whereas using M-x test-b
will behave as you desired.
Even though $0
is used as cursor position, I guess we still should replace the text inside it as well.
Please open an issue in yasnippet
repo instead.