-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
Truncate long filename in header #58
Conversation
The filename will be truncated if it would not fully fit on the screen with the other data on the header.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for taking a stab at this!
I'd suggest splitting this out into a function such that it can be tested better -- we probably also want to always leave space for the modification indicator (such that the header doesn't wiggle when it appears)
maybe a signature like this?
def _header(*, width: int, filename; str, modified: bool) -> str:
...
don't worry about getting the truncation perfect -- a first pass at this is ok (ideally we'd collapse folders first and then the filename last and never leave any partial-end-of-folders, etc.)
centered = filename.center(self.margin.cols)[version_width:] | ||
s = f' {VERSION_STR} {files}{centered}{files}' | ||
|
||
before, after = f' {VERSION_STR} {files}', f'{files}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the second fstring here does nothing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A question about this:
As far as I understand this, the right hand side files indicator would always be offscreen.
Firstly, am I correct in my understanding of this?
Second, is this intentional, should it be shown, or should it just go away?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah that's a mistake on my part 😆 -- it should just go away. that's what you get for writing code while streaming 😆
before, after = f' {VERSION_STR} {files}', f'{files}' | ||
room_for_filename = self.margin.cols - 2 * len(before) | ||
if len(filename) > room_for_filename: | ||
truncate = '... ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the rest of the project utilizes the ellipsis character -- this also makes truncation preserve more characters
Thanks for the feedback, I'll factor the logic out to a function and try to improve this based on the suggestions. |
The filename will be truncated if it would not fully fit on the screen
with the other data on the header.
Addresses some of the problems mentioned in #57