Skip to content
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

XMonad.Prompt freezes if alwaysHighlight= True and maxComplRows is not Nothing #217

Closed
fabiodl opened this issue Nov 19, 2017 · 12 comments
Closed

Comments

@fabiodl
Copy link

fabiodl commented Nov 19, 2017

Problem Description

Especially for XMonad.Prompt.Prompt (but the bug holds for XMonad.Prompt.Window) I set alwaysHighlight to True (to avoid the necessity of pressing tab for selection) but to keep the prompt window reasonably small I set maxComplRows to Just 3
If I have enough choices, so that some of them are not shown, and I keep pressing tab, when I select the first "off screen" one, the prompt freezes. To be specific, the prompt stays there, other xmonad keybindings become available (for instance, switching workspace) while applications do not receive keystrokes anymore (the mouse can be used, however).
stdout reports

user error (Pattern match failure in do expression at XMonad/Prompt.hs:911:3-14)

Expected behavior: as when alwayHighlight is false, complete the prompt with the first invisible entry.

Configuration File

, ((myModKey .|. shiftMask, xK_b ), windowPrompt def{maxComplRows=Just 3,alwaysHighlight = True} Bring allWindows)

Checklist

@byorgey
Copy link
Member

byorgey commented Nov 28, 2017

What version of xmonad are you using?

@fabiodl
Copy link
Author

fabiodl commented Nov 30, 2017

0.13, both installed from cabal or compiled from github.
The one installed from cabal runs on a machine with ghc 7.6.3,
The one manually compiled runs on a machine with ghc 7.10.3

I tried recompiling everything with 8.0.2 and the problem remains. Minimal file:

import XMonad                                                                  
import XMonad.Prompt                                                           
import XMonad.Prompt.Shell                                                     
import XMonad.Util.EZConfig                                                    
                                                                               
main = xmonad $ def `additionalKeys` [                                         
  ((mod4Mask, xK_x),shellPrompt def{maxComplRows=Just 3, alwaysHighlight=Tru
e})                                                                            
  ] 

@byorgey
Copy link
Member

byorgey commented Dec 5, 2017

And when you run the version compiled from github, does it still give the same error Pattern match failure in do expression at XMonad/Prompt.hs:911:3-14?

In fact, line 911 of XMonad.Prompt no longer contains anything which could cause a pattern match failure. So this would indicate that somehow you are actually running an older version of xmonad.

@fabiodl
Copy link
Author

fabiodl commented Dec 5, 2017

Sorry, for the git version it becomes row 914
user error (Pattern match failure in do expression at XMonad/Prompt.hs:914:3-14)

@byorgey
Copy link
Member

byorgey commented Feb 22, 2018

So line 914 is this:

 Just bgcolor <- io $ initColor d (bgColor c)

in what situations could initColor return Nothing? It is a mystery why stuff about completion could affect whether the background color can be initialized successfully.

Just a guess at this point but perhaps the offending change is contained in this commit: 57c00b1#diff-748083b353b28f1e3caf808fbfb0f470

@fabiodl
Copy link
Author

fabiodl commented Feb 26, 2018

I found out that when the error occurs, d seems not valid. Specifically, if I print d I get
Display Prelude.!!: index too large.
However, i have no idea where dpy is set

@geekosaur
Copy link
Contributor

https://github.com/xmonad/xmonad-contrib/blob/master/XMonad/Prompt.hs#L420 and later stuffed into the XPState. But I don't see why this would be relevant to (!!) unless there are two different uses of d with one shadowing the other. dpy is not meaningful to anything but Xlib and the X server.

@fabiodl
Copy link
Author

fabiodl commented Feb 27, 2018

When the error does not occur, d contains something that appears to be a pointer. Is such a pointer actually from a list of pointers?

@geekosaur
Copy link
Contributor

It's a pointer obtained from C to the Xlib Display structure, which is supposed to be opaque to anything other than Xlib internals (but is actually partially exposed if you know which knobs to turn). We obtain it from openDisplay aka XOpenDisplay() and then pass it to other Xlib routines, which is all that an Xlib consumer is allowed to do. (Similar constraints exist on the xcb version.)

@geekosaur
Copy link
Contributor

And I don't think it should ever come from a list, since we can only manage one Xlib Display / Screen at a time. But (!!) arising here means something is being done lazily to get it. I'm not sure what, since the only things I see in Prompt using it are XPState field lookups.

mgsloan added a commit to mgsloan/xmonad-contrib that referenced this issue Jan 24, 2019
mgsloan added a commit to mgsloan/xmonad-contrib that referenced this issue Jan 24, 2019
@mgsloan
Copy link
Contributor

mgsloan commented Jan 24, 2019

In #291 I've fixed the wrap around behavior of tab so that it returns to the first item on reaching the end of the visible completions list.

#287 resolves the exception handling behavior such that the keyboard gets ungrabbed and the prompt windows get destroyed

mgsloan added a commit to mgsloan/xmonad-contrib that referenced this issue Feb 10, 2019
byorgey added a commit that referenced this issue Feb 12, 2019
Fix XMonad.Prompt wraparound when maxComplRows not Nothing #217
@fabiodl
Copy link
Author

fabiodl commented Jul 21, 2020

Really thank you very much, that perfectly solved the issue!

@fabiodl fabiodl closed this as completed Jul 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants