selectrum icon indicating copy to clipboard operation
selectrum copied to clipboard

Minibuffer height and selection with EXWM windows is not correct

Open tslilc opened this issue 5 years ago • 6 comments

Thanks for the good work on this! Unfortunately one of the changes broke the minibuffer height and default candidate selection with EXWM and an X application focussed.

In particular, the top few lines of the minibuffer are not displayed:

strange

but pressing any key causes the it grow and display the default selected candidate (here i pressed C-e, for example):

correct

What can i do to help track down and resolve this problem? Thanks for your attention!

tslilc avatar Apr 21 '20 19:04 tslilc

Yeah, I have seen that problem before, although I wasn't able to figure out how to reproduce it. I think it might have been introduced by 32fe261 or a related commit. If you want to investigate, you could see if the problem is fixed by removing this code: https://github.com/raxod502/selectrum/blob/312626e3f292b18828174fd5ed8a2b0bee58103e/selectrum.el#L747-L749

and you could also bind a key that saves (buffer-string) to a variable, and then type that key directly after entering Selectrum in the screenshot. That way, you could see if the last candidate is missing entirely, or if it is indeed inserted but the window just isn't big enough for some reason.

e.g.

(global-set-key (kbd "C-z") (lambda () (interactive) (setq my-saved-candidates (buffer-string))))

I suspect that what happens is Selectrum gets confused about the rendering of the minibuffer and thinks that it needs to scroll down (implemented by deleting the first line). Fixing that problem would require fixing this code:

https://github.com/raxod502/selectrum/blob/312626e3f292b18828174fd5ed8a2b0bee58103e/selectrum.el#L503-L521

raxod502 avatar Apr 22 '20 14:04 raxod502

Thanks for the prompt response! I can confirm that:

  • removing lines 747-749 ``fixes'' the problem, and
  • saving the buffer contents reveals that selectrum has deleted the first few candidates.

I'm not sure that i understand the internals of selecturm well enough (or at all) to help implement a fix in the location you pointed out. Nevertheless i'd like to do what i can, so if there are more tests i could run for you or some debugging information that might help, just let me know!

tslilc avatar Apr 23 '20 20:04 tslilc

If you could figure out a way to reproduce the problem that anyone can follow (without e.g. having to already have EXWM set up) then that would be the most helpful.

raxod502 avatar Apr 25 '20 14:04 raxod502

I haven't found a way to replicate this without EXWM just yet, but as a work-around i've set the delay in run-with-idle-timer to some small, positive value (0.0001) and it seems to work. I don't think of this as a solution.

The issue appears to be that (window-body-height) reports an incorrect height immediately after the minibuffer is created, perhaps something has to settle?

I'll keep trying.

tslilc avatar Apr 28 '20 19:04 tslilc

Okay, that's helpful to know. I cannot imagine what the reason is, but I suspect that your diagnosis is correct. Maybe somebody will come along and point out that there is a function for computing how many lines a string will take up, and I just missed it.

raxod502 avatar Apr 30 '20 14:04 raxod502

I can reproduce an issue that has the same symptoms as this one by starting a CTRLF search and then typing C-o s to change search styles.

raxod502 avatar May 24 '20 14:05 raxod502