vim / vim

The official Vim repository
https://www.vim.org
Vim License
36.63k stars 5.46k forks source link

Popup window does not resize any longer after scrolling #14745

Open lifepillar opened 6 months ago

lifepillar commented 6 months ago

Steps to reproduce

  1. Run vim --clean
  2. Source this script and take note of the reported popup id (let's say it's 1001):
vim9script

def Popup(): number
  return popup_create([], {
    border: [1, 1, 1, 1],
    close: 'click',
    minheight: 1,
    maxheight: 10,
    scrollbar: true,
    minwidth: &columns - 5,
    maxwidth: &columns - 5,
  })
enddef

var id = Popup()
echo id

popup_settext(id, repeat(['abcd'], 20))
  1. With the mouse, scroll down the popup. This step is crucial to reproduce the issue!
  2. Execute :call popup_settext(1001, []). The popup becomes empty and with minimum height.
  3. Execute :call popup_settext(1001, ['a', 'b', 'c'])

The height of the popup does not change at step 4.

Expected behaviour

I would expect the popup to resize at step 4 to fit the new content. That is what happens if scrolling (step 2) is skipped when performing the above.

Version of Vim

9.1.405

Environment

macOS 14.4.1 Apple Terminal xterm-256color ZSH 5.9

Logs and stack traces

No response

habamax commented 5 months ago

If I scroll with mouse after step 4, window height increases.

lifepillar commented 5 months ago

That's right, scrolling down restores the correct height. But scrolling should not be necessary. If you repeat the steps above skipping step 2, at step 4 the height is restored at once, as expected. I would expect that any call to popup_settext() adapts the popup height (within the minheight/maxheight limits) regardless of the cursor's position.