Bug 436170 - LSP plugin auto-completion should follow "remove tail on complete" setting
Summary: LSP plugin auto-completion should follow "remove tail on complete" setting
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-04-25 15:55 UTC by Ahmad Samir
Modified: 2021-06-06 07:10 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ahmad Samir 2021-04-25 15:55:24 UTC
It looks like when code auto-completion is done by the LSP plugin, it removes the tail by default and there is no setting to change that. Maybe it should follow the global setting in the auto-completion config dialog or have a separate option?
Comment 1 Waqar Ahmed 2021-04-25 16:52:34 UTC
Can you elaborate on the "Removes the tail by default"? I don't understand what you mean by that.
Comment 2 Kåre Särs 2021-04-25 17:27:33 UTC
When you are in the middle of a word and autocomplete a word from the document and have "Remove tail on complete" disabled, it will autocomplete the rest of the completion word, but not remove the end of the "original" word.

autocomplete the word "startComplete" with the cursor at "|" on the following line

start|End

would give:

startComplete|End

in stead of:
startComplete|

(without "End")


Further if the "Remove...." is enabled, the first undo will only undo the removal of the "End", so the completion is done as two separate edit actions...


I have been missing this, but not enough to scratch my itch...
Comment 3 Ahmad Samir 2021-04-25 17:32:00 UTC
An example:
if (fileName.endsWith("foo")) {
....
}
Now if I put the cursor right before "fileName" and type "QStringV", and auto-complete it to QStringView the text becomes:
if (QStringView.endsWith("foo")) {

whereas with "remove tail on complete" (in settings -> Editing -> Auto-Completion) disabled I expect (and that's how it works without the LSP completion, i.e. if I disable the LSP plugin):
if (QStringViewfileName.endsWith("foo")) {

(then I just type the opening '(' and go on ...etc.)

Does that make sense?
Comment 4 Ahmad Samir 2021-04-25 17:32:19 UTC
Mid-air comments collision :)
Comment 5 Bug Janitor Service 2021-05-07 21:47:54 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/kate/-/merge_requests/391
Comment 6 Bug Janitor Service 2021-05-08 15:59:50 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/ktexteditor/-/merge_requests/148
Comment 7 Christoph Cullmann 2021-06-06 07:10:30 UTC
Git commit e337a224309860e0bb50a61a0c012a474457bb29 by Christoph Cullmann, on behalf of Ahmad Samir.
Committed on 06/06/2021 at 07:10.
Pushed by cullmann into branch 'master'.

WIP: Take into account wordCompletionRemoveTail in completionRange() default implementation

If the wordCompletionRemoveTail option is enabled
CodeCompletionModelControllerInterface::completionRange() will return a
range containing the whole word the cursor is inside, which means that the
whole word will be replaced by the selected completion; however if that
option is disabled then it'll return a range containing only the part of
the word on the left of the cursor.

This simplifies the code:
- KateWordCompletionModel::completionRange() is now redundant (finding the
  word start/end is already done in
  CodeCompletionModelControllerInterface::completionRange())
- KateWordCompletionModel::executeCompletionItem() doesn't need to find the
  end of the word being completed, less code

The Kate plugins that implement their own completion models, e.g.
KateProjectCompletion, can now remove their implementation of
completionRange() (which is a copy of KateWordCompletionModel::completionRange());
and the LSPClient plugin completion model now should automatically follow the wordCompletionRemoveTail config option.

M  +1    -46   src/completion/katewordcompletion.cpp
M  +0    -2    src/completion/katewordcompletion.h
M  +5    -1    src/include/ktexteditor/codecompletionmodelcontrollerinterface.h
M  +19   -9    src/utils/codecompletionmodelcontrollerinterface.cpp

https://invent.kde.org/frameworks/ktexteditor/commit/e337a224309860e0bb50a61a0c012a474457bb29