Bug 420966

Summary: After tab-completing to a path (or typing a trailing slash) and hitting enter, Dolphin instead navigates to the first suggested subdirectory of that path
Product: [Applications] dolphin Reporter: andydecleyre
Component: bars: locationAssignee: Eduardo <eduardo.cruz>
Status: RESOLVED FIXED    
Severity: normal CC: andydecleyre, bugseforuns, bugzilla, eduardo.cruz, elvis.angelaccio, jan-bugs, justin.zobel, kfm-devel, mattioli.fernando, mcv, nate, noahadvs
Priority: NOR    
Version: 21.08.1   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=425387
Latest Commit: Version Fixed In: 5.87
Sentry Crash Report:
Attachments: Video demo, trying to navigate to ~/ and ~/.local/
screenshot of misleading entry field
Screenshot of difficult navigation challenge (target: Tela/)

Description andydecleyre 2020-05-03 19:52:23 UTC
Created attachment 128116 [details]
Video demo, trying to navigate to ~/ and ~/.local/

SUMMARY

When I start typing a path in the location bar and tab-complete it, it also shows faintly some deeper-directory completion suggestion, inline.

When I hit Enter to go to the path I typed+tab-completed to, it instead surprises me by navigating to that faintly suggested deeper path. I never want that. 

So now to tab-complete to a folder, it's: type, tab, backspace, enter. Backspace should not be necessary.

STEPS TO REPRODUCE
1. Focus location bar editor
2. Type the beginning of a path which contains subfolders and for which Dolphin suggests subfolder suggestions*
3. Hit <tab> to finish "typing" that path
4. Hit <enter> to navigate to that path

*I actually can't figure out how it's determined whether to show deeper completions for a folder. Some do, some don't.

OBSERVED RESULT

Dolphin navigates to the first suggested subdirectory of the typed+tab-completed path.

EXPECTED RESULT

Dolphin should navigate to the typed+tab-completed path (as in previous releases).

I should need to hit tab again before hitting enter in order to navigate to the first (faint-text) suggestion, and the suggested path should change to non-faint-text if it's going to affect what happens when I hit enter.

The fact that typing the following two sequences has the same navigational result demonstrates the low predictability of (or need for) the current behavior:

<ctrl+l>~/Doc<tab><enter>
<ctrl+l>~/Doc<tab><tab><enter>

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Arch Linux
KDE Plasma Version: 5.18.4
KDE Frameworks Version: 5.69.0
Qt Version: 5.14.2
Comment 1 JanKusanagi 2020-05-03 20:12:41 UTC
Just don't hit TAB, enter a few letters + enter, directly.
Comment 2 andydecleyre 2020-05-03 20:15:42 UTC
(In reply to JanKusanagi from comment #1)
> Just don't hit TAB, enter a few letters + enter, directly.

It is actually not necessary to hit TAB to trigger this bug. In the already attached video demo, I am not using TAB when trying to navigate to ~/.
Comment 3 andydecleyre 2020-05-03 20:18:25 UTC
I suppose then you'll tell me to also not type any final `/`s. That may be a workaround, but IMO the new behavior is still incorrect and an unwelcome change.
Comment 4 andydecleyre 2020-05-03 20:24:40 UTC
Created attachment 128117 [details]
screenshot of misleading entry field

This communicates to me that my cursor is where it's shown to be, that what's really entered so far is the non-faint text, that the faint text is not truly entered, and that the state (or what will happen when I hit enter) differs from one with all that faint text made non-faint. But that is all or mostly effectively false in the current behavior.
Comment 5 andydecleyre 2020-05-03 20:56:32 UTC
Other instances of this kind of suggestion-completion, or of faint text in an entry, that I have found, and how they're not misleading:

- firefox location bar: text is not faint, and is highlighted, and the full entry in the list below is highlighted

- falkon location bar: same as firefox

- krunner: same as firefox

- konsole Find tool: faint text "Find..." does not affect behavior or "true" content of the field at all

- Calligra words font selection entry: text is not faint, and is highlighted

- KDE file dialog: suggestions are not auto-selected; using tab or trailing slash does not activate the suggestions

I couldn't find any other instances of the UI model used here (faint, unhighlighted text suggestion, which is auto-activated; nor suggestions which show as a list below, but don't highlight the auto-activated one).
Comment 6 andydecleyre 2020-05-05 03:29:12 UTC
Created attachment 128158 [details]
Screenshot of difficult navigation challenge (target: Tela/)

At this point, if I finish typing the folder name I want to get to (Tela) without a trailing slash and hit enter, I end up in Tela-black-dark.

If I instead add the trailing slash, I end up in Tela/16@2x.

The best method now is to: 

If I've tab-completed, delete the slash before hitting enter, but if I haven't tab-completed, first type a trailing slash, and then delete it, before hitting enter.
Comment 7 andydecleyre 2020-05-09 03:14:51 UTC
This is just too different from terminal tab completion, and tab completion for previous releases of Dolphin. For anyone else interested, Dolphin 19.12.3 does not have this problem, and I'll be using it as long as I can.
Comment 8 andydecleyre 2020-05-10 22:18:11 UTC
I've found the commit: c33808b125fe339309802dbbc5febad22b40d27a

and the phab item: https://phabricator.kde.org/D25391

"I can't see why one wouldn't want to use this feature"

Ha, please have a look at my comments and attachments.

So I've figured out from that commit, and from reading some of the code at:

https://github.com/KDE/kcompletion/blob/master/src/kcompletion.h

that while not possible via the UI AFAICT, this can be fixed by adding:

UrlCompletionMode=5

to the General section of ~/.config/dolphinrc

So it's solved for me on my computer, but I do think this ought to get a little more attention and consideration from those devs who see no problems with the new behavior (Noah, Nate, Elvis).

Preferably read all the comments and see all the attachments, but if nothing else, those in #6 please.

Thanks for listening!
Comment 9 Noah Davis 2020-05-11 00:39:01 UTC
Perhaps we should make it so pressing Enter doesn't trigger the completion? Or perhaps we should make it so doing a completion doesn't automatically add a slash at the end? It seems that the slash is what causes the field to start showing more completions.
Comment 10 andydecleyre 2020-05-11 18:46:22 UTC
(In reply to Noah Davis from comment #9)
> Or perhaps we should make it so doing a completion doesn't automatically add
> a slash at the end?

If you *only* do this, I don't think that will solve the problem shown in #6: typing an exact path /usr/share/icons/Tela/ and hitting enter would still navigate to some subdirectory like ...Tela/16@2x, and typing the exact path without a slash would navigate to a similarly named but different folder, like ...Tela-black-dark.
Comment 11 Elvis Angelaccio 2020-05-17 21:53:25 UTC
(In reply to andydecleyre from comment #8)
> this can be fixed by adding:
> 
> UrlCompletionMode=5
> 
> to the General section of ~/.config/dolphinrc
> 

You can just right-click the location bar and choose "Text Completion -> Dropdown List", btw.
Comment 12 andydecleyre 2020-05-17 22:07:18 UTC
(In reply to Elvis Angelaccio from comment #11)
> You can just right-click the location bar and choose "Text Completion ->
> Dropdown List", btw.

When I right-click the location bar, the only choices I get are:

- Copy
- Paste
- Edit
- Navigate
- Show Full Path

. . . 

Oh, first get the location bar into editable mode, then do that. Thanks!
Comment 13 Bug Janitor Service 2020-07-14 18:19:27 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/78
Comment 15 Nate Graham 2020-07-19 21:57:50 UTC
*** Bug 424432 has been marked as a duplicate of this bug. ***
Comment 16 andydecleyre 2020-08-13 04:50:24 UTC
So I think the old behavior was to complete a trailing slash, without populating the completion with arbitrary subdirectories. Is there any way to get that old behavior back? I am using the "dropdown list" completion style.

I appreciate that now arbitrary subdirectories are not navigated to all the time as long as I use "dropdown list," but still my habits have been made wrong now -- e.g. typing

    ~/Ima<tab>Wallp<tab>

used to get me to ~/Images/Wallpapers, at least for that since it's an unambiguous completion, but now that fills the location bar with

    ~/ImagesWallp

and puts my focus inside the files pane.

Aside from the problem of breaking old habits, the new behavior of not completing the trailing slash in an unambiguous case offers no benefit over the original behavior and adds an extra inconvenience.

Since navigating to 

    ~/Images 

is the same as navigating to 

~/Images/ 

while the latter text makes it more convenient to navigate to a deeper path, the latter should be preferred.

I will try to patch kcompletion for a personal build if this is not considered a regression by others, to achieve

    /us<tab> -> /usr/ 

rather than 

    /us<tab> -> /usr
Comment 17 andydecleyre 2020-08-18 18:53:08 UTC
For anyone else struggling the way I am, on Arch, my workaround is to:

1) right-click the location bar while it's in editable mode and choose "Dropdown List"

2) build KIO with the above-linked commit (comment 14) reverted, via kio-append-slash from the AUR

I might consider this resolved as invalid simply after learning about changing the completion method to Dropdown List, but now that the "fix" is released I do not consider this resolved, as it just threw an additional problem at the bad behavior, making the existing workaround fail.
Comment 18 andydecleyre 2020-08-19 16:27:55 UTC
Additionally, with the default completion mode, the problematic behavior in the title persists ("...or typing a trailing slash...").

While I would never want that, it is unclear to me if is intentional behavior.
Comment 19 Noah Davis 2020-09-06 13:53:25 UTC
I'm trying a better fix for this now: https://invent.kde.org/frameworks/kcompletion/-/merge_requests/3
Comment 20 Eduardo 2021-08-15 07:10:18 UTC
I too was suffering with the default "Dropdown List & Automatic" text completion behaviour. Changing it to "Dropdown list" with right-click on the address bar fixed all my problems. I'm a much happier person now!

As a user I think the "Dropdown List & Automatic" being the default Text Completion method is not a good decision. If we type "/etc/" and quickly press ENTER, we expect it to go to the "/etc/" folder, not "/etc/acpi/" as is what happens with current default behviour. 

Alro, regarding the TAB usage: when using bash on a terminal, typing "cd /et", pressing TAB once, and pressing ENTER, it takes us to "/etc/" folder. With current Dolphin default behaviour, typing "/et" + TAB + ENTER would lead us unintuitivelly to "/etc/acpi/".

Even the file picker KDialog present in many KDE Addps adopt the "Dropdown list" as the default, so Dolphin is also inconsistent with the rest of KDE environment by default.

I think Dolphin should have a consistent behaviour to the terminal and other file managers by default. New users will feel way more welcomed to adopt it if the default behavior is what they are already expecting. And this desired and expected behaviour is already implemented, it is the "Dropdown List" text completion option.

So here's my plea to change Dolphin's default text completion to "Dropdown List" in upcoming versions.

Also, the option to change the behaviour is a little bit "hidden", I only found it after reading the comments in this bug report. I understand it is Dolphin's philosophy to not be so configurable, but since this IS configurable already, I think it deserves an entry under the "Configure Dolphin" screen, that's where users will go to look for available customizations.
Comment 21 Bug Janitor Service 2021-09-18 05:39:06 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/586
Comment 22 Eduardo 2021-09-19 22:58:07 UTC
Git commit 764f6bd6980fd77b9730d59cbe8a7198bda04a97 by Eduardo de Souza Cruz.
Committed on 19/09/2021 at 22:08.
Pushed by dfaure into branch 'master'.

New shouldAutoSuggest property on KCompletion.

Subclasses may set its value to false to block autosuggestion in special cases.
KLineEdit now reads this property before displaying the autosuggestion.
It's the first step in fixing this bug:

M  +13   -0    src/kcompletion.cpp
M  +18   -0    src/kcompletion.h
M  +1    -0    src/kcompletion_p.h
M  +1    -1    src/klineedit.cpp

https://invent.kde.org/frameworks/kcompletion/commit/764f6bd6980fd77b9730d59cbe8a7198bda04a97
Comment 23 Eduardo 2021-09-20 07:59:40 UTC
Git commit 0a10b3311aef441f748745cfc86828688052209b by Eduardo de Souza Cruz.
Committed on 20/09/2021 at 02:11.
Pushed by dfaure into branch 'master'.

KUrlCompletion blocks autosuggestion from happening if the input is an exact directory path.
Before it was suggesting the first child directory and causing the following bug:

M  +4    -0    src/widgets/kurlcompletion.cpp

https://invent.kde.org/frameworks/kio/commit/0a10b3311aef441f748745cfc86828688052209b