pop-os / cosmic-files

WIP COSMIC file manager
GNU General Public License v3.0
107 stars 77 forks source link

[Feature request] Add tab-completion to path editing. #86

Open XV-02 opened 6 months ago

XV-02 commented 6 months ago

As of dc3c4eb731bc719b4d6ea3c08ac28f5276cae092 users can edit the file path being viewed by clicking the pencil icon next to the trail of breadcrumbs, but do not have tab-completion.

Given both that we support a limited form of tab completion in the launcher, and the general convenience of tab completion, it might make sense to include tab completion in Files as well. At current, hitting tab navigates through elements of the UI, even though the text field is active.

Tab-completion could just be done much as it is in nautilus, where potential completions are shown using a drop down. This might be more familiar as an interface, but I don't how it would be to implement. There is also the question of, with both the left and right side draws, if adding a drop down starts to overwhelm the user with dynamic interactions. But, beyond that, if you attempt to tab-complete in nautilus when there is ambiguity - say trying to tab complete ~/Do when both ~/Documents and ~/Downloads are options - nothing happens. This is arguably not fully featured tab-completion. Similarly, hitting enter on an incomplete path just throws an error, so hitting enter on ~/Do requires the user to dismiss an error and does nothing in terms of presenting useful content.

In light of that, I've spitballed an idea that might help to rethink tab-complete in Files if we want to try for something a bit more.

For the purposes of this, here is an example directory structure:

example
└── Pictures
    ├── Faxes
    ├── Insurance
    ├── Macro
    ├── Portraits
    ├── Vacations
    │   ├── Vacation_2022
    │   ├── Vacation_2023
    │   ├── Vacation_2024
    │   └── Wedding
    └── Wallpapers

If I want to navigate directly to the Vacation_2022 folder, I might start in my root "example" folder and edit the path directly. To do this, I may type /Pictures/Va and then attempt to tab-complete. As the only sub-directory beginning with Va is Vacations this should tab-complete to /home/example/Pictures/Vacations

S1-2

Note that this does not change the content in view. Because there is no ambiguity in what the next viable tab-completion is, there is no need to change what the user sees.

Next, I might type /Va and attempt to tab-complete again. This should tab-complete to the fullest extent it can - /home/example/Pictures/Vacations/Vacation_202 - and present all the potential full completions. This might require search to be implemented to do, however.

S2-3

Normally, the /home/example/Pictures/Vacations in this example should contain Wedding as well, but that is filtered out, as it is not a valid tab-completion. Effectively, this creates a GUI equivalent of the tab completion functionality in a TTY, where attempting a tab-complete on cd Va while in ~/example/Pictures/Vacations results in the following:

daniel@pop-os:~/example/Pictures/Vacations$ cd Vacation_202
Vacation_2022/ Vacation_2023/ Vacation_2024/

By changing the content being displayed, the user's attention is drawn to the change. By only doing this when tab-completion requires disambiguation, it makes it more evident that that the incomplete tab-completion and the option presented are linked.

Tab-completion does raise a couple of questions though:

First, the question of what to do if the user hits enter on an incomplete path needs addressing. The most logical solution is to dump the user into the directory which corresponds to the part of the file path that is completed, and to present the indeterminate portion as search results. In this example, because /home/example/Pictures/Vacations/Vacation_202 is incomplete, hitting enter should dump the user into the /home/example/Pictures/Vacations directory, and display search results for Vacation_202.

Second is what to do if a user hits enter on a file. Currently, hitting enter on a path that matches to a non-existent directory "shows" the directory. The directory doesn't exist, but the file manager acts as though it does until any action which would require the directory to exist is made, in which case an error is thrown. This is a much more knotty question, and I wonder if the same behaviour as launcher uses - of opening the file in the correct application - should be taken or if instead, the directory containing the file should be opened with the file highlighted.

michalfita commented 1 month ago

There's pattern in many UIs that when any potential completion can be done w/o ambiguity the grey suggestion is shown after cursor. In IDEs Control+Space usually finishes completion then, but in shell/file access, Tab finishes such completion. If more than one option is possible a form of a drop-down is displayed.