Skip to content

Conversation

MatinAniss
Copy link
Contributor

@MatinAniss MatinAniss commented Jul 31, 2025

Partially addresses this issue #5294

Adds a selector between LF and CRLF for the buffer's line endings, the checkmark denotes the currently selected line ending.

Selector
image

Release Notes:

  • Added line ending selector.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jul 31, 2025
@MatinAniss MatinAniss changed the title Add line ending selector Add line ending selector and display Jul 31, 2025
@domi413
Copy link
Contributor

domi413 commented Jul 31, 2025

Can we have a setting to disable the indicator in the status bar?

@MatinAniss MatinAniss marked this pull request as draft July 31, 2025 19:12
@MatinAniss
Copy link
Contributor Author

MatinAniss commented Aug 2, 2025

Can we have a setting to disable the indicator in the status bar?

I don't think the other indicators on the status bar like the line/column position, vim mode, and language have a way of disabling them either, so I'm not sure how the Zed team would want something like that implemented. I'm not really sure what the setting would look like since they are indicators specific to buffers.

I would think that these "buffer indicators" would be grouped together under one scope, rather than each having their own individual property at the root level of the settings.

@domi413
Copy link
Contributor

domi413 commented Aug 2, 2025

Understandable. The reason I'm asking that is, in my opinion, there are already too many buttons and indicators in the status bar, and since I don't care about the line ending 99% of the time, I would like to disable it (as I did in vscode).

@ConradIrwin
Copy link
Member

Thanks for this!

I agree that we shouldn't show the line ending in the status bar. It is rarely useful. I don't think we even need a setting to enable it: what are the workflows where you continually need to know your files line-endings?

If there are some we should try and figure out how to solve those, maybe Zed could respect the end_of_line property from https://editorconfig.org, so that it could default to the correct value for all files in the project. (Though it's unclear if it should automatically fix line-endings for any file that's edited, or just use this for new files that are created).

We do need some way to surface the current line ending, but I think that would be as simple as having the picker show a check-mark next to the currently selected item.

@ConradIrwin ConradIrwin self-assigned this Aug 12, 2025
@MatinAniss MatinAniss force-pushed the line-ending-selector branch from 5e0f6f9 to 42e3a60 Compare August 20, 2025 18:04
@MatinAniss
Copy link
Contributor Author

For workflows where a line ending indicator would be beneficial, working on cross platform projects it is nice to quickly be able to see the line ending of a file without having to open up the selector. Having the option for the indicator would be nice and just defaulting with it disabled, but as you said the selector with the checkmark does work.

I do agree that Zed should use the editor config property, currently when creating new file in a project it just uses the line ending of the system rather than what is used in the project, also a user setting is needed for the desired default line ending, could look into these in a separate PR.

@ConradIrwin
Copy link
Member

I guess so; though it's hopefully a very large minority of the time :D.

The approach here seems reasonable to me (including without undo). I think we need to make it work over collab too (or less ideally disabling it in that case)? Do you feel comfortable doing that and adding a test? If not happy to pair: https://cal.com/conradirwin/pairing.

@anddam
Copy link

anddam commented Aug 27, 2025

I am not even sure I should be commenting on a PR but here it goes

@domi413

Understandable. The reason I'm asking that is, in my opinion, there are already too many buttons and indicators in the status bar, and since I don't care about the line ending 99% of the time, I would like to disable it (as I did in vscode).

Would having two commands, a setter and a getter that only displays the current line ending, be a reasonable approach?

This way you would call "show line ending" command and read the current setting in a modal palette rather than having the space taken in the status bar.
Then if need be you'd call "set line ending" command and pick the desired value from the selector.

@MatinAniss MatinAniss changed the title Add line ending selector and display Add line ending selector Sep 1, 2025
@MatinAniss
Copy link
Contributor Author

I removed the line ending display from this PR to keep things simple. When selecting a line ending from the selector it will now save the buffer instead of marking it as dirty since that can cause confusion because you can't undo it. I added a test and the buffer operation UpdateLineEnding but I haven't actually tested it over collab.

@ConradIrwin
Copy link
Member

Great, thank you!

I pushed up a change that fixes the problem over collab (the defer is needed so that the save happens after the line ending change is propagated). I also removed the editor from the picker as it seemed unnecessary.

Is there anything else you wanted to do before shipping this?

@MatinAniss
Copy link
Contributor Author

Thanks, nothing else, good to go!

@MatinAniss MatinAniss marked this pull request as ready for review September 3, 2025 06:15
@ConradIrwin ConradIrwin merged commit b3405c3 into zed-industries:main Sep 5, 2025
23 checks passed
@ConradIrwin
Copy link
Member

Thanks!

@MatinAniss MatinAniss deleted the line-ending-selector branch September 5, 2025 16:53
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.

5 participants