Skip to content

Conversation

@kitt-cat
Copy link
Contributor

@kitt-cat kitt-cat commented Oct 6, 2025

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_button setting.

  • 9926237 changes status_bar.line_endings_button from a boolean to an enum:

    show details
    • always Always show line endings indicator.
    • non_native Indicate when line endings do not match the current platform.
    • lf_only Indicate when using unix-style (LF) line endings only.
    • crlf_only Indicate when using windows-style (CRLF) line endings only.
    • never Do not show line endings indicator.

    I know this many options might be overdoing it, but I was torn between the pleasant default of non_native and the simplicity of lf_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):

the gap after the indicator is larger than for other buttons

I started a new follow-up PR to address that: #39992

Release Notes:

  • Added line ending indicator to the status bar (disabled by default; enabled by setting status_bar.line_endings_button to true)

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Oct 6, 2025
@semioticrobotic
Copy link

Amazing. Thank you so much for this, @kitt-cat.

@ConradIrwin
Copy link
Member

@kitt-cat nice!

  • I think the padding is due to the invisible status item about language_toolchain between the two existing items. I think we can fix that by adding a new method to the settings trait is_visible() and filtering the invisible ones out here:
    .children(self.right_items.iter().rev().map(|item| item.to_any()))
  • I think we should stick with true/false for now (although I'm also excited by the idea of "it shows up when you need it", it seems unnecessarily fiddly – how do we know whether a file is expected to have "\r\n" or "\n"? And then when you change the line ending the UI disappears on you, which is a bit weird?).
  • Change to the action name seems reasonable (makes it more consistent)

@kitt-cat kitt-cat force-pushed the kittcat/line-endings-in-statusbar branch from 623507d to 9701b1d Compare October 8, 2025 13:43
@kitt-cat

This comment was marked as outdated.

@ConradIrwin
Copy link
Member

ConradIrwin commented Oct 8, 2025

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?

@kitt-cat kitt-cat force-pushed the kittcat/line-endings-in-statusbar branch from 9701b1d to a0b8659 Compare October 9, 2025 19:07
@kitt-cat

This comment was marked as outdated.

@zed-industries-bot
Copy link

zed-industries-bot commented Oct 9, 2025

Messages
📖

This PR includes links to the following GitHub Issues: #5294
If this PR aims to close an issue, please include a Closes #ISSUE line at the top of the PR body.

Generated by 🚫 dangerJS against be5241c

@kitt-cat kitt-cat force-pushed the kittcat/line-endings-in-statusbar branch from a0b8659 to 0117419 Compare October 11, 2025 02:24
@kitt-cat
Copy link
Contributor Author

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
@kitt-cat kitt-cat force-pushed the kittcat/line-endings-in-statusbar branch from 0117419 to be5241c Compare October 11, 2025 15:25
danilo-leal pushed a commit that referenced this pull request Oct 17, 2025
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.

![before using display:none theres extra spaces, afterwords the buttons
are always evenly
spaced](https://github.com/user-attachments/assets/3bd07837-5f6f-4ca1-8985-9f3cb8b6893d)

- 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
P1n3appl3 pushed a commit to P1n3appl3/zed that referenced this pull request Oct 18, 2025
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.

![before using display:none theres extra spaces, afterwords the buttons
are always evenly
spaced](https://github.com/user-attachments/assets/3bd07837-5f6f-4ca1-8985-9f3cb8b6893d)

- 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
@ConradIrwin ConradIrwin merged commit f7a0971 into zed-industries:main Oct 20, 2025
22 checks passed
@ConradIrwin
Copy link
Member

Thanks again for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support CRLF / LF line-endings display and modification

6 participants