Skip to content

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.
@afnanenayet afnanenayet force-pushed the afnan/truncate-paths-in-hdr branch from 77c9fc0 to b744abd Compare September 23, 2024 13:46
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