-
-
Notifications
You must be signed in to change notification settings - Fork 276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unclear semantics for Prompt completions #610
Comments
I don't think that anyone who extensively worked on the prompt is still active, so at this point it's patchworks all the way down :) I would say that the "expected" semantics are those who users—right now—expect to have happen. Essentially, go wild. Many of your examples of the prompt's inconsistency essentially stem from the problem that we don't exactly know which part of the currently entered prompt the user wants to have completed. There are some examples (like the shell prompt) where a user may have entered a command, a space, and then wants a directory auto-completed without touching the initially entered command. Other times things separated by spaces are to be treated as one thing; this creates some friction.
It would certainly make the code a lot simpler. I personally don't have anything against this approach (then again, I always use |
I haven't checked all the prompts, but in the case of the shell prompt it is using the default completion implementations for As an initial project I could rewrite the default completion code as a I described above and save the current implementation outside of the typeclass. Then we can use the old completion code in the instance definitions for all prompts that currently rely on it. |
On Sun, Oct 03 2021 16:35, Solomon Bothwell wrote:
As an initial project I could rewrite the default completion code as a
I described above and save the current implementation outside of the
typeclass. Then we can use the old completion code in the instance
definitions for all prompts that currently rely on it.
Go wild 👍
|
Will do :) |
I'm still working on this. I'm putting together a more minimal prompt design in a seperate cabal project for more rapid prototyping. It isn't ready to discuss here but there is another Prompt related issue I would like to bring up. The I think we should just turn |
Would this be as extensible as the current system? It seems less so, but this may just be my initial impression. It seems like we would just switch from having an "up-front cost" by using type classes to delaying this until later. E.g., especially when using multiple modes it's currently very easy to decide which function to call exactly (just query Another thing to think about here is just how much user code this would break |
Unless I am missing something subtle, we would have identical behavior but the code would be a lot more explicit.
How many people are actually writing their own |
Mh interesting. I would almost say "go for it" if we didn't have to at least somewhat keep backwards compatibility in mind :/
I have never understood this either, but I've seen small prompts in quite a few user configurations. This may or may not still be something that we want to do at some point, but perhaps we should take this one step at a time (first fix the completion system, then talk about refactoring the core types) |
Sorry for the slow response time. I've been caught up with work stuff. We can keep the typeclass for now, but we are going to need to change it substantially. It just doesn't really capture what it means to be a prompt. I have a working prototype in a scratch project that uses this interface:
Ignore the fact that I used a record, this would be the core of a new To make it more consistent, I broke up the act of completing the Command from shifting the focus. How we complete a command is highly dependent on the particulars of the Prompt--such as with the shell prompt--but shifting focus in the completions is always the same. Internally in my demo project I used a Zipper for storing completions so we it is easy to shift focus. I don't think the This set of functions is able to handle simple prompts as well as complex IO heavy prompts like the shell prompt. Here are two examples to show simple and IO based prompts:
My demo project is in a larger scratch repo. I'll break it into its own repo and link it here this week so that you can have a look at it. I'm not married to this specific design, but I think we shouldn't be stuck with 14 year old technical debt out of fear of making breaking changes for users. |
If we're making a breaking change anyways then there's no harm with going all the way and using the better design. I was just under the impression that the completion refactor you were planning was going to be backwards compatible with the current interface, which is why I had reservations about using a record.
Well, XMonad has a track record of being really rather stable and not breaking too many things (even with 0.17.0 we somehow managed to not really have any gigantic breaking changes, which this would definitely be). This certainly needs to be deliberated thoroughly.
That sounds good 👍 The examples looks nice and make me hopeful that we can move forward with this idea in spite of the huge breaking change it would introduce |
@solomon-b any updates on this? |
@slotThe thank you for the reminder. I got really caught up with work stuff and then various other side projects. i had made some progress on a branch but at this point its probably out of date. I still want to do this work, but i think it will have to wait until March. |
On Wed, Feb 23 2022 11:35, Solomon wrote:
I still want to do this work, but i think it will have to wait until
March.
Not a problem at all! When you feel comfortable with the basic design
do feel free to open a PR—I'm more than willing to help you iron out any
remaining kinks and/or start porting the prompt modules to the new
interface
|
Thank you! I'll reach out when I get back into it. |
@solomon-b Well, this was a while ago :) Is this still something you're interested in tackling? |
Oh my. I can't believe its been so long since i looked into this. I have somewhat mixed feelings about this project now. I could be convinced otherwise but I'm wondering if the prompt system should be considered out of scope for XMonad. Especially given the call to action for migrating to Wayland I am thinking it might be worth considering what we could drop to make the Wayland migration realistic. What if we broke out a bunch of features like prompts into standalone applications and then came up with really nice story for how everything can communicate at runtime? |
Contribs, including Prompt, will need to be redone for a Wayland port anyway. And at minimum Prompt should be changed to hook into the I am not sure that runtime communication will work for all the uses of Prompt in contrib. |
As geekosaur already said, pretty much all of contrib (and definitely the prompt) will have to be scrapped for Wayland anyways, so "future compatibility" is not super relevant here, I think. I reckon most of the prompts that exist could be emulated with external applications like dmenu or rofi. Still, having this built into XMonad feels like a nice thing to me :) Since the prompt is already a thing, considering it out of scope now will not happen, so I think that trying to improve it is still a worthwhile goal. |
I actually disagree about external applications: many uses of the prompt alter internal xmonad state. One might argue that you could use xdotool for many of them, but xdotool doesn't exist (and can't with their current permissions model) for Wayland. And improving it now will still guide a later Wayland port. |
Problem Description
I'm pretty motivated to put in some work on
XMonad.Prompt
. There is a lot of potential improvements around navigation and scrolling through commands. However, the semantics of the completion system are very unclear and possibly buggy. Is there anyone here who can give me clear explanation of the expected behavior of the completions system?I'm going to give some examples of weird behavior of completions. I'm hoping we can determine which of these behaviors are intended, which are bugs, and finally define the semantics for completions. If we can do that then I would like to refactor this module a bit in anticipation of doing some feature work to extend the Prompt interface.
Simple Completions (
alwaysHighlight == False
)I am using an
XMonad
prompt because they are very simple and use the default definitions ofXPrompt
.Given the prompt:
Tab completion works as I would expect. If I have entered nothing into the command line then pressing
tab
cycles between all the completion list options. If I enterb
and presstab
, it cycles betweenbar
andbaz
.Now if I change the prompt to use two words per completion:
Now I get what I would consider a bug. The first
tab
sets the prompt to1 foo
and subsequenttabs
prepend the command line with more1
s.This behavior is actually no surprise considering the default implementation of
nextCompletion
:Given the default
XPrompt
definitions, what happens here is that we lookup the last word of the command line in the completion list--that word would befoo
in our case--which will never be found thus settingnl = 0
. Then the command line minus the last word is prepended to the entire completion string at index 0 and returned.Based on the haddock description of this function, I believe what it should be doing is filtering the completion list for entries which contain the last word of the command line. I have no idea why this is a useful behavior for tab completion but that is what the haddock sort of describes.
highlight completions (
alwaysHighlight == True
)The
hlComplete
code is a lot more confusing. Not so much to follow the subroutines, but to understand the desired behavior.The user experience of of high completions feels pretty similar to simple completions modulo edge cases.
Using the same prompt from earlier:
The
tab
key with no command input cycles through all the available completions. If I typeb
thentab
cycles between2 bar
and3 baz
.It gets weird if you enter a multiword command. For example, if you type
"foo "
(that is with a space after foo) then you get the entire completion list. I would expect this to either yield no completions (there is no completion with "foo " as a substring) or it would yield the1 foo
completion (by stripping the trailng space from the "search").If after typing
"foo "
you then presstab
, the highlight stays on1 foo
, the command gets replaced withfoo 1 foo
, and the completion list is still unfiltered. Subsequent pressed oftab
cycle the highlighted completion and change the command to that completion prepended with"foo "
, until you cycle back to the first completion and the prependedfoo
goes away.If we use another prompt example I can show another strange behavior:
If I enter
1
as my command then the search options are filtered down to1: Capture Screen
. Now if I press tab then the command is replaced with1: Capture Screen
as expected, however the completion options are also now extended to include3: Capture All Screens
. i have not been able to replicate this behavior with any other prompts or command inputs.Proposal
If someone can outline the intended behavior for both completion types then I would be happy to write a PR eliminating whatever edge cases are not intended as part of that behavior.
Alternatively I would propose we eliminate the distinction between both completion types and replace them with a simple fuzzy filter of the completion options based on the currently entered command and the
tab
key can cycle through the filtered list of completions.alwaysHighlight
would be either removed or not do anything (depending on how we handle deprecation of type parameters).LIke I said, I am motivated to work on and expand the functionality of
XMonad.Prompts
. I want to do some cooler stuff like pagination and multiselect but before I can get there I think we need to have sensible behavior for completions.Checklist
I've read CONTRIBUTING.md
I tested my configuration
xmonad
commit 33a86c0cdb9aa481e23cc5527a997adef5e32d42xmonad-contrib
commit 20fdcbaThe text was updated successfully, but these errors were encountered: