Skip to content

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.

@komar007
Copy link
Author

I'm not sure I want to provide the extra dependencies to calculateSize to calculate this properly, because it doesn't seem like this was the intention. I guess setting item list height via a preview window setting is not the best idea after all.

Maybe it would be cleaner to implement another option (--list-height/--max-list-height) to explicitly set the number of items.

What I'm trying to achieve here is a full-size window in tmux mode that shows all provided items (there are always rather few - it is a tmux session switcher) with potentially some limit just in case, and with the preview window taking up the rest of the screen.

@junegunn
Copy link
Owner

Maybe it would be cleaner to implement another option (--list-height/--max-list-height) to explicitly set the number of items.

I guess so. But let's not rush into a decision. In this case, we also need to design how things should look when the preview window is not visible, or positioned on the right or left.

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