flycheck-pos-tip icon indicating copy to clipboard operation
flycheck-pos-tip copied to clipboard

Make a tooltip position configurable according to other menus

Open ddovod opened this issue 8 years ago • 10 comments

Hi. I have some issue with tooltip. Instead of thouthand words please look at the picture http://imgur.com/w2Daspa

Is there any solution? Thank you a lot!

ddovod avatar Feb 06 '16 14:02 ddovod

This is going to be really hard to fix; the other menu is from autocomplete, right? I don't think there's a way for us to autodetect its width, so we'd have to have a special case for every package that displays a menu (company, ac, ...)

Of course, I'm hoping @lunaryorn to prove me wrong :)

cpitclaudel avatar Feb 06 '16 15:02 cpitclaudel

I tend to agree with @cpitclaudel: I don't think that we can easily prevent this sort of thing. I'm inclined to close this issue was "wontfix".

swsnr avatar Feb 07 '16 10:02 swsnr

At best, we could provide an option to adjust tooltip placement, but I'm not firm enough with pos-tip to implement that.

swsnr avatar Feb 07 '16 10:02 swsnr

I'm having the exact same problem, but since I only manually complete I'd be happy with a way to disable the pos-tip when the completion menu is showing. Any ideas how to accomplish this?

ambihelical avatar Jul 06 '16 04:07 ambihelical

@ambihelical You can remap the command that starts completion to a defun of your own that would call pos-tip-hide before calling through to the completion function. I can give more details if needed :)

cpitclaudel avatar Jul 06 '16 04:07 cpitclaudel

I tried it but it doesn't completely solve the problem, as flycheck can cause the tooltip to reappear while the completion menu is still showing. I will probably look into temporarily disabling flycheck next, as there seems to be hooks for completion start and stop.

A potentially simple way to fix this for everyone would be if there was an option to always place the tooltip above the line, and then the two popups shouldn't interfere.

ambihelical avatar Jul 10 '16 18:07 ambihelical

call pos-tip-hide before calling through to the completion function

I think it's a good solution.

seagle0128 avatar Sep 06 '17 02:09 seagle0128

@seagle0128 Did it work for you? It's been awhile but as I said, it seem to be possible for pos-tip-show to be called again while the completion menu is still active, and I seem to recall this occurring during my experiments.

I ended up doing the following, it has worked so far for me, but requires saving and restoring the flycheck-pos-tip-error-messages function, which seems a bit of a hack to me.

Partial config follows.

(use-package company
  :init
  (add-hook 'company-completion-started-hook #'me:company-started)
  (add-hook 'company-completion-finished-hook #'me:company-ended)
  (add-hook 'company-completion-cancelled-hook #'me:company-ended)
  :config
  (defvar me:flycheck-error-function nil)
  (defun me:company-started (&optional args)
    (when (fboundp 'flycheck-pos-tip-error-messages)
      (setq me:flycheck-error-function (symbol-function 'flycheck-pos-tip-error-messages))
      (fset 'flycheck-pos-tip-error-messages 'ignore)))

  (defun me:company-ended (&optional args)
    (when (fboundp 'flycheck-pos-tip-error-messages)
      (fset 'flycheck-pos-tip-error-messages me:flycheck-error-function))))

ambihelical avatar Sep 06 '17 05:09 ambihelical

@ambihelical Honestly I didn't try this workaround. But it seems your workaround works as well.

seagle0128 avatar Sep 06 '17 07:09 seagle0128

Thanks for sharing that. I think we should have an API to temporarily suspend Flycheck. It turns out that autocomplete already uses advice to override an internal function and disable Flycheck while completing, so that API would be useful there too.

cpitclaudel avatar Sep 06 '17 16:09 cpitclaudel