abo-abo / swiper

Ivy - a generic completion frontend for Emacs, Swiper - isearch with an overview, and more. Oh, man!
https://oremacs.com/swiper/
2.31k stars 338 forks source link

Minibuffer collapses to one line after switching to another OS window (Alt-TAB) #1751

Open ChoppinBlockParty opened 6 years ago

ChoppinBlockParty commented 6 years ago

When I am using ivy minibuffer, I sometimes need to switch to another OS window (Alt-TAB), after I come back to this emacs window ivy minibuffer is collapsed to one line and only prompt is seen. Is it possible to avoid this behavior?

amosbird commented 6 years ago
(defun +amos*ivy--insert-minibuffer (text)
  "Insert TEXT into minibuffer with appropriate cleanup."
  (let ((resize-mini-windows nil)
        (update-fn (ivy-state-update-fn ivy-last))
        (old-mark (marker-position (mark-marker)))
        deactivate-mark)
    (ivy--cleanup)
    (when update-fn
      (funcall update-fn))
    (ivy--insert-prompt)
    ;; Do nothing if while-no-input was aborted.
    (when (stringp text)
      (if ivy-display-function
          (funcall ivy-display-function text)
        (ivy-display-function-fallback text)))
    (unless (frame-root-window-p (minibuffer-window))
      (with-selected-window (minibuffer-window)
        (set-window-text-height nil
                                (+ ivy-height
                                   (if ivy-add-newline-after-prompt
                                       1
                                     0)))))
    ;; prevent region growing due to text remove/add
    (when (region-active-p)
      (set-mark old-mark))))
(advice-add #'ivy--insert-minibuffer :override #'+amos*ivy--insert-minibuffer)

It'll expand the minibuffer once you input something.

ChoppinBlockParty commented 6 years ago

Hmm..., for some reasons it did not fix the behavior for me.

abo-abo commented 6 years ago

Can't reproduce with Emacs-26.1 on Linux.

ChoppinBlockParty commented 6 years ago

Emacs version: 26.1 Operating System: Ubuntu 16.04 Evil version: 1.2.13 Evil installation type: MELPA Graphical/Terminal: X

ChoppinBlockParty commented 6 years ago

selection_017

That is how it looks like. I notice this only happens when the window is maximized (in the screenshot it is not maximized, because I first maximized it switch to another window/desktop, and then resized it).

abo-abo commented 6 years ago

Tried with emacs -nw on a maximized terminal window. Still can't reproduce. Did you try with make plain?

ChoppinBlockParty commented 6 years ago

I found exactly when it happens, it happens when there is resizing. Long story, I am using awesome wm, and when window is focused I have 1px red border, so when the windows are tiled on the screen and I switch from one window to another a window is actually resized due to this border.

Is it possible to preserve the minibuffer window during resizing?