Bug 316413

Summary: Autocomplete breaks text entering when pressing ENTER
Product: [Applications] kate Reporter: Wolfgang Illmeyer <wolfgang.illmeyer>
Component: kwriteAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: major CC: christoph, linux.news, zanetu
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Bug Depends on: 320955    
Bug Blocks:    

Description Wolfgang Illmeyer 2013-03-09 13:11:24 UTC
Autocomplete shouldn't interfere with normal text entry. In this case it does, because as soon as autocomplete kicks in, i MUST press escape to close it. If I press enter instead, it doesn't go to the next line, as expected, but executes the autocomplete. This is especially annoying, since autocomplete even kicks in on a paste operation.

This breaks the following major features:
a) Text entry using a keyboard
b) Usage of clipboards

I first noticed this behaviour in kwrite-4.10

Reproducible: Always

Steps to Reproduce:
1. Use some text field, editor, or browser to enter "http://www.google.com/search?q=goo" (without quotes)
2. Copy it to clipboard using either "copy" or X-Window selection
3. Paste it into kwrite by using either "paste" or MOUSE3, accordingly to step 2
4. Press Enter to go to the next line

or alternatively:
1. Enter the following text by keyboard into a new file in kwrite: "http://www.google.com/search?q=goo" (without quotes)
2. Press Enter
Actual Results:  
You end up with this line:
http://www.google.com/search?q=google
and the cursor still at the end of the line.

Expected Results:  
You end up with this line:
http://www.google.com/search?q=goo
and the cursor is at the beginning of the next line.

I'd suggest to alter the auto completion behavior as follows:
As soon as there is a suggestion, open up the autocompletion window, but do not select any of the suggestions yet. The user is now informed, that he can use autocomplete.

If he wants to use it, he presses "Arrow down", "Arrow up" or clicks somewhere at the autocomplete window. Now he can select the desired completion and presses "Enter", just as before.

If he doesn't want to use it (e.g. he didn't see it, because he was reading the the originial text he was typing, etc.), he continues writing as before. Any keystroke short of up- or down-arrow has the same effect on the autocomplete window as pressing escape now. The user can even use "Enter" to go to the next line, without accidentally triggering autocomplete. Only if he uses the up- or down arrow keys or clicks somewhere, he could accidentally trigger autcomplete, but in these cases, he will most probably look concentrated at the edit control anyways and won't be surprised by autocomplete kicking in.

Also: Under NO circumstances have autocomplete triggered by some kind of paste operation.
Comment 1 Dominik Haumann 2013-06-27 10:36:59 UTC
In KDE >= 4.11, the auto completion popup never shows on paste now, neither on ctrl+v nor for middle mouse button. Can we consider this issue fixed?
Comment 2 Wolfgang Illmeyer 2013-06-27 20:49:12 UTC
Hmm... I was being stupid for submitting two issues in one bugreport. Technically, there would still be the problem if autocomplete kicks in just before I press enter for a newline, it autocompletes without my approval and if in that moment I look at the original text I'm typing, without my knowledge. Should I resubmit that in a separate bug?

Also, my distro doesn't carry kde>=4.11 as of yet.
Comment 3 Christoph Cullmann 2014-09-26 20:08:13 UTC
Sorry, but auto-complete really works ok the way it is. If we alter that behavior, we will get many more reports about that than with the current way.
Comment 4 Wolfgang Illmeyer 2014-09-27 09:34:54 UTC
I'm sorry to hear that. I think an editor (and even more a good one) should support the user in his work and not put hurdles in his way by deliberately and systematically introducing errors. There are many other editors that don't _interfere_ with simple _typing_(!). I'm afraid I'll have to switch then :(
Comment 5 Christoph Cullmann 2014-09-27 15:44:13 UTC
You can deactivate the auto completion in the settings. Then you can invoke it manually. If that doesn't help, then yes, Kate is perhaps not the best choice, sorry.
Comment 6 Ben Bucksch 2020-11-20 13:28:17 UTC
This bug is probably the most infuriating misfeature of Kate. I love Kate and use it for everything, and the autocomplete *is* very useful. But only on tab, not on Enter.

This is made worse by the fact that it takes any word already in the document as autocomplete candidate. That means, if anywhere in the document is the word "kate", I can no longer type "k" on its on line, by typing "k[ENTER]". It will always write "kate". What's most infuriating is that it's insisting on it. Even if I correct it and delete "ate", leaving only "k" as I wanted, and press enter to get to the new line, it will again autocomplete to "kate".

A text editor should write whatever I type, not something completely different. An autocomplete must always be activated intentionally by the user and not happen by itself.

What is useful is:
* k[TAB] -> kate
* k -> dropdown opens -> [ARROW DOWN][ENTER]
I need that autocomplete all the time. I cannot disable it.

What's buggy is:
* k[ENTER] -> kate\n

What's expected is:
* k[ENTER] -> k\n

That expected result shouldn't be too surprising, because that's exactly what I typed, and a text editor needs to write what I type, and not something completely different.

This is a bug.

If you insist that some people like the buggy behavior, then you can make a pref. But please allow me to use the editor properly, and to use autocomplete in a way that's useful and not interfering with normal typing.
Comment 7 Ben Bucksch 2020-11-20 13:30:45 UTC
> You can deactivate the auto completion in the settings

I need autocomplete, and I need kate. I just cannot have this bug here.
Comment 8 Ben Bucksch 2020-11-20 13:34:03 UTC
dhaumann wrote on <https://stackoverflow.com/questions/33361672/remove-auto-completion-with-enter-key-in-kate-text-editor>:

Send a patch,... and we will likely accept it ;)
Comment 9 Bug Janitor Service 2021-02-18 15:30:56 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/ktexteditor/-/merge_requests/106
Comment 10 Jan Paul Batrina 2021-02-19 14:54:06 UTC
Git commit 3733a2b4b7a6813820ce7a55196e64ccfed4e90d by Jan Paul Batrina.
Committed on 19/02/2021 at 14:09.
Pushed by jbatrina into branch 'master'.

Add option to preselect nothing when automatic completion is invoked

Since the first entry was previously always preselected, it sometimes
made entering newlines (with the return key) hard for users who are not
familiar with Shift+Enter.

M  +4    -1    src/completion/katecompletionwidget.cpp
M  +7    -0    src/dialogs/completionconfigtab.ui
M  +3    -0    src/dialogs/katedialogs.cpp
M  +1    -0    src/utils/kateconfig.cpp
M  +6    -0    src/utils/kateconfig.h

https://invent.kde.org/frameworks/ktexteditor/commit/3733a2b4b7a6813820ce7a55196e64ccfed4e90d