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

Popup stays open when switching windows #112

Closed
minad opened this issue Jan 29, 2022 · 21 comments
Closed

Popup stays open when switching windows #112

minad opened this issue Jan 29, 2022 · 21 comments
Labels
enhancement New feature or request

Comments

@minad
Copy link
Owner

minad commented Jan 29, 2022

Auto completion in scratch -> switch to eshell via C-c e.

@aconchillo
Copy link

Popup stays open for me despite having, both in lsp-mode or geiser.

  (setq corfu-quit-no-match 'separator)

@minad minad changed the title Popup stays open Popup stays open when switching windows Feb 8, 2022
@minad
Copy link
Owner Author

minad commented Feb 8, 2022

@aconchillo Your bug is probably a different bug. It sounds like an issue in your configuration. Can you reproduce this with a minimal recipe based on emacs -Q, with only a minimal set of packages loaded?

@aconchillo
Copy link

@minad Yes, my bad. The problem was because I copy pasted this:

(use-package orderless
  :init
  ;; Configure a custom style dispatcher (see the Consult wiki)
  ;; (setq orderless-style-dispatchers '(+orderless-dispatch)
  ;;       orderless-component-separator #'orderless-escapable-split-on-space)
  (setq completion-styles '(orderless)
        completion-category-defaults nil
        completion-category-overrides '((file (styles . (partial-completion))))))

With this corfu doesn't quit when there's no match but I am sure there is more to tweak. Since I'm not sure I need orderless I just removed it and corfu quits as expected now.

@aconchillo
Copy link

A little bit more info. If orderless is not setup and you type for example (use-package, as soon as you press space the popup will go away (which is my preference). With orderless setup (with above config) if you type (use-package and then you hit space, the popup doesn't close. You need to keep typing (something else different than spaces) for the popup the close, but then it will open again for the next completion and so on.

@AkibAzmain
Copy link

Is this issue still present?

@minad
Copy link
Owner Author

minad commented Jun 28, 2022

Yes, this happens mainly when invoking a command which switches the buffer after some time (run-ar-time). Then Corfu will not observe the switch and not close the popup. But it is a rare problem.

@AkibAzmain
Copy link

AkibAzmain commented Jun 28, 2022

Then Corfu can add some function to hooks like window-scroll-functions, window-size-change-functions, window-state-change-functions, window-buffer-change-functions, window-selection-change-functions, and obviously window-configuration-change-hook. Note that all functions in these hooks are not handled in the same way; (info "(elisp) Window Hooks") describes them all.

@minad
Copy link
Owner Author

minad commented Jun 28, 2022

@AkibAzmain Yes of course. I just haven't done this until now since it happens only rarely. If you want you can create a PR which fixes this small issue.

@AkibAzmain
Copy link

AkibAzmain commented Jun 28, 2022

I won't try to implement this right now, because I have not completed paperwork yet, and maintaining a fork of a package requires simply too much effort (I'm already doing this for Eglot, see joaotavora/eglot#839).

@minad
Copy link
Owner Author

minad commented Jun 28, 2022

@AkibAzmain Is it possible for you and are you willing to complete the paperwork?

@AkibAzmain
Copy link

AkibAzmain commented Jun 29, 2022

Yes, I think, there is no legal problem. But I have some personal problems, preventing me from doing it now.

@agzam
Copy link

agzam commented Nov 7, 2022

Is there at least a function to remove the stale pop-up? It's kinda annoying when it weirdly floats around, e.g. when using tab-bar mode.

@minad
Copy link
Owner Author

minad commented Nov 7, 2022

@agzam When does the issue occur in your setup? Can you create a minimal recipe starting from emacs -Q? We can probably handle all these issues as described in #112 (comment).

@agzam
Copy link

agzam commented Nov 8, 2022

I mean aside from the issue, I'm sure there's some mechanism to remove the existing pop-up, right?

What does corfu use? is it a posframe? I'm using GUI Emacs on Mac. Can I find it in within (frame-list), does it have a unique attribute?

@minad
Copy link
Owner Author

minad commented Nov 8, 2022

@agzam child frame. See corfu--frame.

@agzam
Copy link

agzam commented Nov 9, 2022

I'm sorry for not cooperating, I just re-installed my system anew and I'm still trying to restore things, I have not installed chemacs2 yet. Also, I switched to corfu just a few days ago and haven't had a chance to explore the code.

And this issue is a tough one, it's not easily reproducible. It can happen often enough to feel annoying, but now I can eval (delete-frame corfu--frame).

It's not ideal but works most of the time. Sometimes though, it still leaves a blank artifact - a rectangle area that has nothing but still blocks the text behind it.
update: it looks like it was botched corfu-doc--frame - sometimes it would remove its content, but still leave the frame "shadow" that covers the area and just sits there. Running these together fixes the problem for me:

(delete-frame corfu--frame)
(delete-frame corfu-doc--frame)

I think I'm gonna try to wrap it into a function and attach it to some hooks.

@minad
Copy link
Owner Author

minad commented Nov 9, 2022

@agzam In my setup, this problem occurs almost never. Corfu is quite solid overall. I would really need a recipe to reproduce the most common scenario, if we want this fixed. It could also be a Mac-specific issue. In that case, I cannot do anything about it without help since I don't have a Mac around. But I recommend switching to a free platform anyway. ;)

@agzam
Copy link

agzam commented Nov 9, 2022

this problem occurs almost never. Corfu is quite solid overall.

Yes, this doesn't happen often, that's why it's difficult to reproduce.

It could also be a Mac-specific issue.

Could be. Also, I'm using Emacs 29. With --native-comp flag. Any of these factors can contribute to the cause. That's why I'm hesitant on trying to repro it on emacs -q. See, I have never complained about the issue. For me, a function to remove all the corfu frames that I can bind to a key (at least for now) is quite sufficient.

I recommend switching to a free platform anyway

I know, right? It's not up to me, though. Unfortunately, my employer, for a bunch of bureaucratic reasons, painted as "security", forces me to use a Mac.

Anyway, apologies for the noise. And thank you for all the amazing work you do. I know, could be extremely frustrating, when someone complains about the work that you enthusiastically shared without asking for a single dime or any appreciation for it. But at this point you probably know, a lot of people in the Emacs community seriously love the completion stack you've created, and I am with them. You have my sincerest gratitude.

@Eason0210
Copy link

Eason0210 commented Nov 19, 2022

Hi @minad

I can reproduce this issue with the steps as below:

  1. emacs -q to launch Emacs, then package-refresh-contents
  2. Install corfu (package-install 'corfu)
  3. Enable auto complete and set (setq help-window-select t)
(global-corfu-mode 1)
(setq corfu-auto t)
(setq help-window-select t)
  1. Type some code in *scrath* buffer, until the candidate window pop up, such as type (mes
  2. C-h k and then C-g , now you will see the issue as below picture.

I am using Emacs 29.0.50, macOS 13.0.1

image

@minad
Copy link
Owner Author

minad commented Nov 19, 2022 via email

@Eason0210
Copy link

Eason0210 commented Nov 19, 2022

I cannot reproduce in on Emacs 28

I can not reproduce in Emacs 28.2 too, on macOS.
Now it clear, it only happen on macOS with Emacs 29.

agzam added a commit to agzam/.doom.d that referenced this issue Nov 23, 2022
minad added a commit that referenced this issue Dec 23, 2022
I am not sure if this change also fixes other edge cases of #112.
@minad minad added the enhancement New feature or request label Jan 15, 2023
@minad minad closed this as completed in 00cca1f Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants