-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Add line endings indicator in status bar #39609
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 line endings indicator in status bar #39609
Conversation
|
Amazing. Thank you so much for this, @kitt-cat. |
|
@kitt-cat nice!
|
623507d to
9701b1d
Compare
This comment was marked as outdated.
This comment was marked as outdated.
|
We could maybe try downcasting the element returned by render, but it's probably clearer overall to make the logic explicit. For ones that aren't causing problems (i.e. anything except the language toolchain selector) it seems fine to leave is_visible as true? |
9701b1d to
a0b8659
Compare
This comment was marked as outdated.
This comment was marked as outdated.
a0b8659 to
0117419
Compare
|
Hello again, I moved the spacing related changes in a new PR (#39992) to manage scope creep, if that is ok! I hope this PR may be merge-ready now, is there anything more you'd like to see? |
Add a line ending indicator to the status bar, disabled by default but can be enabled with `status_bar.line_endings_button` as discussed in https://redirect.github.com/zed-industries/zed/issues/5294
0117419 to
be5241c
Compare
This is a follow-up PR to #39609, and attempts to address hidden status bar items still contributing to the layout and creating extra spacing.  - 203cbd6 Adds a `.none()` method to the `gpui::Styled` helper trait, so that status items can set their display type to none inside their `render` method. - 249f06e Applies `.none()` to all the status items. - ~~499f564906c88336608c81615b11ebc9ab43d832~~ At first I was adding an `is_visible` method to the `StatusBarView` trait, which would be used to skip status bar items which would just render an empty div anyway, but I felt duplicating the conditions for hiding the buttons between the status items `is_visible` and `render` methods could be an attraction for bugs, so I tried to find another approach. This commit contains those changes, reverted immediately (if the `is_visible` approach is preferred I can bring it back!) - f37cb75 (bonus!) Adds a condition to the vim mode indicator to avoid a leading space when there are no pending keys. Release Notes: - N/A
This is a follow-up PR to zed-industries#39609, and attempts to address hidden status bar items still contributing to the layout and creating extra spacing.  - 203cbd6 Adds a `.none()` method to the `gpui::Styled` helper trait, so that status items can set their display type to none inside their `render` method. - 249f06e Applies `.none()` to all the status items. - ~~499f564906c88336608c81615b11ebc9ab43d832~~ At first I was adding an `is_visible` method to the `StatusBarView` trait, which would be used to skip status bar items which would just render an empty div anyway, but I felt duplicating the conditions for hiding the buttons between the status items `is_visible` and `render` methods could be an attraction for bugs, so I tried to find another approach. This commit contains those changes, reverted immediately (if the `is_visible` approach is preferred I can bring it back!) - f37cb75 (bonus!) Adds a condition to the vim mode indicator to avoid a leading space when there are no pending keys. Release Notes: - N/A
|
Thanks again for this! |
Closes #5294
This PR adds a line ending indicator to the status bar, hidden by default as discussed in #5294.
Changes
8b063a2 add the indicator and
status_bar.line_endings_buttonsetting.9926237 changesstatus_bar.line_endings_buttonfrom a boolean to an enum:show details
alwaysAlways show line endings indicator.non_nativeIndicate when line endings do not match the current platform.lf_onlyIndicate when using unix-style (LF) line endings only.crlf_onlyIndicate when using windows-style (CRLF) line endings only.neverDo not show line endings indicator.I know this many options might be overdoing it, but I was torn between the pleasant default of
non_nativeand the simplicity oflf_only/crlf_only.My thinking was if one is developing on a project which exclusively uses one line-ending style or the other, it would be nice to be able to configure no-indicator-in-the-happy-case behavior regardless of the platform zed is running on. But I'm not really familiar with any projects that use exclusively CRLF line endings in practice. Is this a scenario worth supporting or just something I dreamed up?
0117419 rename the action context for
line ending: Toggle->line ending selector: Toggle.When running the action in the command palette with the old name I felt surprised to be greeted with an additional menu, with the new name it feels more predictable (plus now it matches
language_selector::Toggle!)Future work
Hidden status bar items still get padding, creating inconsistent spacing (and it kind of stands out where I placed the line-endings button):
I started a new follow-up PR to address that: #39992
Release Notes:
status_bar.line_endings_buttontotrue)