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

Add support for max_preview_height setting #1088

Merged
merged 2 commits into from Jul 31, 2023

Conversation

RichardDRJ
Copy link
Contributor

This allows for more configuration around show_preview, specifically in the case where someone has shell commands spanning more than 4 lines in their history and need to differentiate between them with something other than the first few lines.

This change makes the following supporting changes:

  • Update the preview renderer to split lines when they go past the preview width, rather than splitting the whole string - this means that the preview is cleanly rendered even in cases where there are newlines
  • Update the preview height size calculator to take into account existing newlines

A couple of other notes here:

  • I've never written rust before, so very open to being told I've done something iffy here
  • I think this strips out empty lines from the preview - I'm not sure the best way to fix it given my lack of Rust experience, but given that any more than 4 lines was cut off before, I'm not sure there'll be any visible regression

Screenshots

style = "compact"
show_preview = true
max_preview_height = 6

Short command with longer commands in history

image

Long command, longer than 4 lines but shorter than max_preview_height

image

Longest command in history, longer than max_preview_height

image


style = "full"
show_preview = true
max_preview_height = 6

Short command with longer commands in history

image

Long command, longer than 4 lines but shorter than max_preview_height

image

Longest command in history, longer than max_preview_height

image

@vercel
Copy link

vercel bot commented Jul 6, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
atuin ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 6, 2023 8:49am

This allows for more configuration around `show_preview`, specifically in the case where someone has shell commands spanning more than 4 lines in their history and need to differentiate between them with something other than the first few lines.

This change makes the following supporting changes:

- Update the preview renderer to split _lines_ when they go past the preview width, rather than splitting the whole string - this means that the preview is cleanly rendered even in cases where there are newlines
- Update the preview height size calculator to take into account existing newlines
ellie
ellie previously approved these changes Jul 31, 2023
Copy link
Member

@ellie ellie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense and is a nice improvement, thank you!

Seeing as this is your first time contributing, if you would like a holographic contributors-only Atuin sticker, then please fill out this form!

We do also have a Discord if you'd like to ask any questions, or just fancy hanging out!

@ellie ellie enabled auto-merge (squash) July 31, 2023 08:35
@ellie
Copy link
Member

ellie commented Jul 31, 2023

Looks like it needs a cargo fmt! Should be good otherwise

auto-merge was automatically disabled July 31, 2023 09:26

Head branch was pushed to by a user without write access

@RichardDRJ
Copy link
Contributor Author

Oops, thanks @ellie! Have addressed and pushed - hopefully it's all good 😄

@ellie ellie merged commit d7f8929 into atuinsh:main Jul 31, 2023
16 checks passed
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.

None yet

2 participants