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

ui: truncate paths in hdr box #956

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

afnanenayet
Copy link
Owner

@afnanenayet afnanenayet commented Aug 23, 2024

Add string utilities and apply string truncation to the top of the header box where we show the filenames being diffed.

If you have a diff between two files with very long paths where a path might exceed the length of the terminal, diffsitter used to display something like this:

terminal width:
--------------------
/a/very/long/path.txt
/a/very/long/other_p
ath.txt

And if your terminal was too short, the text would wrap around.

Now it will look something like this:

terminal width:
--------------------
/a/very/long/path.txt
/a/ve/...other_path.txt

@afnanenayet afnanenayet force-pushed the afnan/truncate-paths-in-hdr branch 3 times, most recently from 8998967 to 77c9fc0 Compare August 26, 2024 18:12
Adds a module for string utils and a small utility function to truncate
strings.
Adds a macro to more efficiently concatenate strings, since I noticed
there is some code I have to concatenate strings that use
`format!("{}{}...{})`, which might not be particularly efficient.

This macro is also much more ergonomic to use.
When rendering a diff in the "unified" style, a long path name will be
truncated to fit the terminal width in the box at the top where we
display the filenames being diffed.
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.

1 participant