-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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 option to limit length of tab titles #5718
Conversation
You dont need ctype in the option definition as this option is only used by python code. |
Okay, fixed |
I believe the naming of this configuration option is not accurate, however I did not raise it in time before the merge. I also have a question about the placement of this option in |
I looked at it again and the option name look accurate, however I am not sure this is what the user expects. The length of the tab includes left and right decorations, abbreviations |
Indeed, I think it would be better to truncate the title instead. @kovidgoyal I think your commit 5c50e38 doesn't actually fix the problem: try
The fading separators get cropped. The Something like: def draw_title(draw_data: DrawData, screen: Screen, tab: TabBarData, index: int, max_title_length: int = 0) -> None:
+ tab_title = tab.title
+ if draw_data.max_title_length > 0 and len(tab_title) > draw_data.max_title_length:
+ tab_title = tab.title[:draw_data.max_title_length] + '…'
ta = TabAccessor(tab.tab_id)
data = {
'index': index,
'layout_name': tab.layout_name,
'num_windows': tab.num_windows,
'num_window_groups': tab.num_window_groups,
- 'title': tab.title,
+ 'title': tab_title,
'tab': ta, Would crop only the title |
max_tab_length is not used in draw_title its used after draw title. |
And you cant use python string lengths to truncate strings, they dont correspond to visual lengths, you need to use truncate_point_for_length. And you cant truncate just the tab title, since the actual remdered title is based on a template that can process the tab title in arbitrary ways. |
See 722a102 |
This PR adds an option to truncate tab titles above a certain length.
I find it annoying sometimes to have very long commands take up lots of screen space for their tab titles. Related to #1494, but it's not exactly what was requested: tab_min_length would need to be added to have a fixed tab size, but I find just setting a max length good enough for my use case.