Closed ronandalton closed 2 months ago
I created a PR that fixes this issue. I went with my alternate suggestion of setting the default clip_columns
and flip_lines
values to the preview_cutoff
values for the vertical and horizontal layouts. This should be more robust since if those values change, these values won't get out of sync again. It also means less configuration is needed if a user changes their default preview_cutoff
values.
Description
When using the flex layout with default settings, odd behavior is observed when resizing the window horizontally. The preview pane is hidden at certain widths.
Neovim version
Operating system and version
Linux 6.8.1
Telescope version / branch / rev
master (c2ce039)
checkhealth telescope
Steps to reproduce
nvim -nu minimal.lua
:Telescope live_grep
Expected behavior
The preview pane should remain visible while resizing horizontally. The layout should flip to vertical once the width is reduced below 120.
Actual behavior
There is a period while resizing horizontally where the preview pane is not visible. This happens between widths of 120 and 100. When the window width is reduced below 100, the preview appears again in a vertical layout. This doesn't make sense because if you started with a vertical layout, you wouldn't expect increasing the width of the window to show less of the UI.
Video: https://github.com/nvim-telescope/telescope.nvim/assets/86718942/f8e272a0-b719-4752-9adc-fa08f085c099
Analysis
The reason this happens is because of a mismatch between the default
flip_columns
andflip_lines
values (which are 100 and 20) for the flex layout and thepreview_cutoff
values for the horizontal and vertical layouts (which are 120 and 40). When the window width is increased to 100, the horizontal layout is switched to, but the horizontal layout won't display a preview pane because the window width is below the preview cutoff for the horizontal layout.My suggested change would be to set the default
flip_columns
andflip_lines
values in the flex layout code to 120 and 40 respectively. This would ensure the vertical layout is only switched away from when the window is wide enough for the horizontal layout to display correctly. Alternatively, the defaultclip_columns
andflip_lines
values could be taken from thepreview_cutoff
values for the horizontal and vertical layouts automatically.Note that the desired behavior can be achieved just by adding the following code to telescope's config, but as I consider the default behavior a bit strange, I thought it might be better to have that changed so this config isn't needed.
Minimal config