Closed ayoub-benali closed 5 years ago
One idea could be that we:
We know:
textEdit
textEdit
Therefore we can assume that the remaining can simply deleted.
Example
// first
def myF<ctrl+space>
// after user choice we get broken code
def override def myFunction1(): Unit = ???
// finaly delete the borken prefix with a diff between and range and last prefix
override def myFunction1(): Unit = ???
The whole challenge is to somehow know which choice the user make so we can decide which fix we need to apply if need to be
@rwols can you think of a case where this logic would brake things ?
@ayoub-benali Unfortunately, I don't see good solution for this, other than making Sublime Text aware of completion text replacement ranges. The problem is that the completion prefix myFunction
CtrlSpace and its completion text override def myFunction1(): Unit = ???
starts before the prefix.
This is shortcoming of Sublime Text that does not provide explicit way to apply replacement with explicit range. It does only replace current prefix with proposed text, see https://github.com/tomv564/LSP/pull/295#discussion_r175924508.
Therefore I have added feature request to Sublime Text there: https://github.com/SublimeTextIssues/Core/issues/2754
When autocomplete has to edit before the completion position the trimming introduced in https://github.com/tomv564/LSP/pull/295 leads to a bug, see line
You can see an example bellow using Scala with Metals:![broken-autocomplete](https://user-images.githubusercontent.com/1632384/54742160-dde3ab00-4bc0-11e9-9f73-a9078ddecec7.gif)
Here is the
CompletionItem
sent back by the server:Expected behavior
Before:
After:
Please note the bug doesn't happen when the prefix is fully specified:![broken-autocomplete-2](https://user-images.githubusercontent.com/1632384/54742571-189a1300-4bc2-11e9-9c9a-77b77158bee6.gif)
Any ideas on how to fix this kind of issues ? I am willing to make a PR but first would like to get your thoughts
cc @nanoant