tigersoldier / company-lsp

Company completion backend for lsp-mode
GNU General Public License v3.0
251 stars 26 forks source link

Fix range of snippet expansion with textEdit. #88

Closed tigersoldier closed 5 years ago

tigersoldier commented 5 years ago

When expanding snippets, company-lsp calls yas-expand-snippet which replaces text within given range with the insert text. Currently, the start of the range is set to the start of the prefix. However, in some cases the start of text edit range can be different from the start of the prefix. For example in lsp-java (JDTLS), when completing java.util, the start of prefix is before util. However the candidate can be java.util.List, whose start of range is before java. Because currently we are using the prefix start, java.util will become java.java.util.List, which is caused by replacing util with java.util.List.

This change should fix emacs-lsp/lsp-java#95 and emacs-lsp/lsp-java#46

tigersoldier commented 5 years ago

@yyoncho Please try this out. Your PR was reverted because it breaks filtering.

tigersoldier commented 5 years ago

BTW, I copied your commit description about emacs-lsp/lsp-java#95, but I think the issue it fixes is emacs-lsp/lsp-java#67. It's unclear to me how your PR was fixing emacs-lsp/lsp-java#95.

yyoncho commented 5 years ago

It works fine.

emacs-lsp/lsp-java#95 is typo, the proper issue is https://github.com/emacs-lsp/lsp-java/issues/46 .