Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support setting preview window's size to achieve a specific items list size #4314

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

komar007
Copy link

This PR implements negative preview window sizes which result in adjusting the preview window's size such that the items list has a specific size.

I didn't find a way to achieve this specific behavior where I want a full-size window with a specific small size of the list and a preview that takes the rest of the space.

Negative size adjusts the preview window to achieve desired item list size
@junegunn
Copy link
Owner

Thanks. But I noticed this option doesn't work nicely with adaptive --height.

# Works as expected
seq 10 | go run main.go --preview 'echo {}' --preview-window up:10  --height ~100%

# Doesn't work as expected
seq 10 | go run main.go --preview 'echo {}' --preview-window up:-10  --height ~100%

# Crashes
seq 10 | go run main.go --preview 'echo {}' --preview-window up:-20  --height ~100%

Also, I wonder if have you tested it with the extra borders. Are these the results you expected?

# 10 items in the list section
seq 100 | go run main.go --preview 'echo {}' --preview-window up:-10
seq 100 | go run main.go --preview 'echo {}' --preview-window up:-10 --info=inline
seq 100 | go run main.go --preview 'echo {}' --preview-window up:-10 --no-input

# 8 items in the list
seq 100 | go run main.go --preview 'echo {}' --preview-window up:-10 --input-border
seq 100 | go run main.go --preview 'echo {}' --preview-window up:-10 --list-border

# 6 items
seq 100 | go run main.go --preview 'echo {}' --preview-window up:-10 --style full

# 3 items
seq 100 | go run main.go --preview 'echo {}' --preview-window up:-10 --style full --header hello

@komar007
Copy link
Author

komar007 commented Mar 18, 2025

Thanks, @junegunn,

I didn't know about adaptive height, I'll look into this and the other extra borders problem. I just tested with variations of --border and --preview-window ...,border-none

Let me work some more on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants