eclipse / lsp4e

Language Server Protocol support in Eclipse IDE
Eclipse Public License 2.0
65 stars 54 forks source link

adjustments to additionalTextEdits are slightly off when on different line (when applying a proposal) #896

Closed martinlippert closed 9 months ago

martinlippert commented 9 months ago

I have content-assist proposals with additionalTextEdits that affected pieces of the document behind the current cursor position. But it looks like the position of the additionalTextEdits, when applied, is not adjusted with regards to a potential changed document.

Here is the exact case:

Please note that the extra call to the server to resolve completion proposals doesn't help here, because this resolve call gets called when the user scrolls to the completion proposal in the UI (the proposals popup), it does not happen after the user typed additional characters.

martinlippert commented 9 months ago

Another note: This is, of course, only necessary if the additionalTextEdits have a start offset that is greater than the cursor position (at the time of requesting the completion proposals).

AdditionalTextEdits that appear before the current cursor position (e.g. automated insertion of new import statements) work nicely, of course.

martinlippert commented 9 months ago

Actually, I debugged through the code a bit and it looks like there is code already to adjust the AdditionalTextEdits - and it looks like this adjustment is actually the problem... :-)

The additional text edit contains a line number and a character number in that line. So as long as the additional text edit is on a different line than the completion happened, the adjustment does NOT need to happen - at least this is what is looks like to me.

martinlippert commented 9 months ago

@vrubezhny I saw you implemented the related code in 9915647c28a934d376f86ecdfcc58382441ff54f, do you remember the exact use case you had for this? Seems like I need to understand this in more detail

mickaelistria commented 9 months ago

Fixes with #897