tumashu / ivy-posframe

ivy-posframe is a ivy extension, which let ivy use posframe to show its candidate menu, ivy-posframe is a **GNU ELPA** package.
414 stars 26 forks source link

Ivy-posframe doesn't display all the candidates when min-height is 0 #108

Open thomasheartman opened 3 years ago

thomasheartman commented 3 years ago

Hi,

First off: thanks for a great package!

Issue

I have an issue where the posframe doesn't seem to resize correctly. More specifically, it seems to be a line to short when displaying certain numbers of candidates and using a :min-height of 0 or 1.

In the below screenshot, I have two buffers that match the search, but the posframe only shows the first. This seems to happen also when there are three or four matches (and presumably more). As such, I'm thinking this might be due to some form of misconfiguration on my part, but I don't know.

2021-01-02-190029_2906x109_scrot

It seems that ivy-posframe always displays at most ivy-height - 1 candidates, which may explain what's happening here (but which might also be completely unrelated).

Goal

What I'd like to achieve is for the posframe to be as short (have as few rows) as possible. It should have at least one (the current prompt) and at most ivy-height or ivy-posframe-height (or one fewer, depending on how it's calculated). If there are fewer candidates than ivy-height - 1, then the height should be equal to candidate-count + 1, where candidate-count are the current number of displayed candidates. In other words: there should never be any blank rows, but there should also never be any visually hidden rows if the prompt is smaller than specified in ivy-height.

Thanks for any and all input!

(This issue also relates to this comment on a fixed-width issue in this repo and to this question/issue on the swiper repo.)

Edit: Clarified goal section.

thomasheartman commented 3 years ago

A little update on this: I managed to make it work by counting the number of ivy completion candidates:

(defun my-ivy-posframe-get-size ()
    "Set the ivy-posframe size according to the current frame."
    (let* ((height (or ivy-posframe-height (or ivy-height 10)))
           (min-height (min height (+ 1 (length ivy--old-cands))))
           (width (min (or ivy-posframe-width 200) (round (* .75 (frame-width))))))
      (list :height height :width width :min-height min-height :min-width width)))

This now works correctly most of the time. However, I still see empty rows below all the options sometimes when the min-height is less than 10 (the default). But it's not consistent, so I can't replicate it. What I do know, though, is that the extra row shouldn't be there based on the given min-height (that is, min-height is set to the right number excluding the empty row).

BooAA commented 3 years ago

Hi,

First off: thanks for a great package!

Issue

I have an issue where the posframe doesn't seem to resize correctly. More specifically, it seems to be a line to short when displaying certain numbers of candidates and using a :min-height of 0 or 1.

In the below screenshot, I have two buffers that match the search, but the posframe only shows the first. This seems to happen also when there are three or four matches (and presumably more). As such, I'm thinking this might be due to some form of misconfiguration on my part, but I don't know.

2021-01-02-190029_2906x109_scrot

It seems that ivy-posframe always displays at most ivy-height - 1 candidates, which may explain what's happening here (but which might also be completely unrelated).

Goal

What I'd like to achieve is for the posframe to be as short (have as few rows) as possible. It should have at least one (the current prompt) and at most ivy-height or ivy-posframe-height (or one fewer, depending on how it's calculated). If there are fewer candidates than ivy-height - 1, then the height should be equal to candidate-count + 1, where candidate-count are the current number of displayed candidates. In other words: there should never be any blank rows, but there should also never be any visually hidden rows if the prompt is smaller than specified in ivy-height.

Thanks for any and all input!

(This issue also relates to this comment on a fixed-width issue in this repo and to this question/issue on the swiper repo.)

Edit: Clarified goal section.

Same issue here.