-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 title box to Picker
#8155
Add title box to Picker
#8155
Conversation
Preivously, if the length of the string was even The string would underflow and the vertical bar on the line with title string would underflow
The title now shows the number of diagnostics based on severity like follows: "Diagnostics: [5 E] [0 W] [1 I] [0 H]"
The title now shows the `user_entered_regex` and if the search is case sensitive or not taking `smart_case` into account
I am not a fan of adding a title it feels unnecessary and tahkesup more vertical space. With #7265 there will be a heading for each column so at that point it gets too much |
I would agree with you that the title would be redundant if it just displayed some static information but for something like global search, the additional context the title provides is quite helpful, have a look: As for the concerns regarding limited vertical space, I'm working on an implementation that just adds title to the top of existing picker instead of shrinking the picker to make room for the title box. |
Could we not display the title inline with the bounding box at top, similar to what we do with the title for keymap modes? |
This reverts commit b75bd3e.
I quite like the look of the second option, but from a minimal point of view the first is best. Curious what others think. |
Me too though you might wanna have a look at my original post which I have since updated with the new changes to title rendering. Would a configuration option be better? Something like |
Since the promp/commandline at the bottom is always empty when a picker is opened, can't we just put this information there? It wouldn't take up any extra space and would still be there for those that need it. |
I don't think the title being at prompt would be very intuitive for pickers that are primarily launched via keymaps, like the file picker but I could see it working for the global search picker. |
It’s definitely not intuitive to put it in the prompt, and I wouldn’t want it inconsistent from picker to picker . Global search will eventually not use the prompt anyway, once interactive global search gets done. I say (without much authority) we go for the configurable but on by default approach, similar to how autoinfo is there by default but can be configured off by those who prefer not to have the noise. A big draw of the editor is contextual help or intuitive/unsurprising behavior. As for which style to use, since the works already done I don’t see any harm in keeping both versions as part of configuration. My bias is again to use the prettier version as the default. |
I agree, it's probably the best to let users decide for themselves. For now, I have implemented the configuration options for all the suggestions presented above namely: |
|
||
| Key | Description | Default | | ||
|--|--|---------| | ||
| `picker-title` | Renders a title for the opening picker. Can be `never`, `center`, `inline`, `inline-border` or `prompt` | `never` | |
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 formulation here can make a non-fluent reader think that the title will be never
, center
, ...
What do you think about:
| `picker-title` | Renders a title for the opening picker. Can be `never`, `center`, `inline`, `inline-border` or `prompt` | `never` | | |
| `title-format` | How the picker's title is displayed. Can be `never`, `center`, `inline`, `inline-border` or `prompt` | `never` | |
let picker_title = format!( | ||
"Global Search: '{}' {}", | ||
regex, | ||
if case_sensitive { | ||
"[Case Sensitive]" | ||
} else { | ||
"[Case Insensitive]" | ||
} | ||
); |
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.
With a long regex, this will be quite unreadable, the length of the displayed regex should be limited to the N (to determine) first chars of it.
|
||
let picker_title = format!( | ||
"Diagnostics: [{} E] [{} W] [{} I] [{} H]", |
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.
I think just: {} E, {} W, {} I, {} H
will be enough and have less sigils to read. Commas are easier to skip than []
too
cx.editor.set_error(err); | ||
} | ||
}) | ||
let picker_title = format!("Files in {:?}", root.as_os_str()); |
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.
This will also have the length problem and should probably be collapsed, only expand the last N directories, if it reaches the width limit of the windows
surface.set_string( | ||
// Add two for spacing for border box and margin | ||
area.x + 2, | ||
area.y + 1, | ||
&self.title, | ||
text_style, | ||
); |
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.
Yes I think the picker title will overflow if it is too long, I remember hitting this with inline diagnostics
I am going to close this PR. This also already has conflicts and will become very hard to rebase once #9647 is merged. I don't think we want to add this feature in this form. This is a mimor visual feature where I just don't think it's worth or necessary to invest the effort. Thank you for contributing. |
Fixes #8139
The current implementation of the picker doesn't display any context information about what it's displaying.
This PR adds a
title
field to thePicker
struct and implements the necessary logic for proper rendering of the title box based on the config optionPickerTitle
.This changes the rendering of a picker as follows:
The
title
is exposed to the caller viaPicker::new()
andPicker::with_stream()
functions.I have added the following as the titles for now:
global_search
user_entered_regex
' [case_sensitive
]buffer_picker
jumplist_picker
command_palette
file_picker
current working directory
sym_picker
diag_picker
errors
E] [warnings
W] [informations
I] [hints
H]lsp_workspace_command
goto_impl
thread_picker
dap_launch
dap_switch_stack_frame
Screenshots
Changes to Picker:
File Picker:
Global Search Picker:
Diagnostics Picker:
Videos
Dynamic Titles:
2023-09-04_14-13-16.mp4
Rendering Options:
2023-09-09_23-07-40.mp4