Skip to content
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

Line ending detection #224

Merged
merged 28 commits into from
Jun 22, 2021
Merged

Line ending detection #224

merged 28 commits into from
Jun 22, 2021

Conversation

janhrastnik
Copy link
Contributor

@janhrastnik janhrastnik commented Jun 11, 2021

…\n', as this fixes CRLF files not rendering properly. Code that inserts line endings still needs to be changed and a platform default line ending could be added.
@archseer may I ask why slice here isn't a borrow like in the original code?

Fixes #118
Fixes #68

@janhrastnik janhrastnik mentioned this pull request Jun 11, 2021
helix-view/src/document.rs Outdated Show resolved Hide resolved
helix-view/src/document.rs Outdated Show resolved Hide resolved
helix-view/src/document.rs Outdated Show resolved Hide resolved
helix-view/src/document.rs Outdated Show resolved Hide resolved
helix-core/src/line_ending.rs Outdated Show resolved Hide resolved
helix-view/src/document.rs Outdated Show resolved Hide resolved
helix-view/src/editor.rs Outdated Show resolved Hide resolved
helix-view/src/document.rs Outdated Show resolved Hide resolved
helix-view/src/document.rs Outdated Show resolved Hide resolved
helix-view/src/document.rs Outdated Show resolved Hide resolved
@archseer archseer changed the title added line ending detection and '\r\n' is now being matched same as '… Line ending detection Jun 12, 2021
helix-term/src/ui/editor.rs Outdated Show resolved Hide resolved
@janhrastnik
Copy link
Contributor Author

@archseer I started replacing some occurances of '\n' in commands.rs. I noticed that a lot of places take in '\n' as a char, not a &str. But doc.line_ending() returns a &str, because (as much as I understand) "\r\n" is 2 characters long. Any ideas what to do here? Also I can't call doc.line_ending() at some points because doc can't be instantiated there yet because of lifetime errors.

@cessen
Copy link
Contributor

cessen commented Jun 14, 2021

@archseer I started replacing some occurances of '\n' in commands.rs. I noticed that a lot of places take in '\n' as a char, not a &str. But doc.line_ending() returns a &str, because (as much as I understand) "\r\n" is 2 characters long.

Any place that needs a line ending as a literal should take a &str for sure, due to the CRLF case as you noted. I think the lifetime issues can be dealt with by ensuring that all cases are &'static str, which shouldn't be hard for line endings: we have a limited set of known possible strings.

Something else that occurred to me is we could have LineEnding implement a to_str() method as well, that just returns a &'static str representation. I'm not sure if that would actually be useful enough in Helix's code base to justify the impl, so maybe no a good idea. But just a thought.

helix-term/src/commands.rs Outdated Show resolved Hide resolved
helix-term/src/commands.rs Outdated Show resolved Hide resolved
helix-term/src/commands.rs Outdated Show resolved Hide resolved
@archseer archseer self-requested a review June 17, 2021 16:27
helix-term/src/commands.rs Outdated Show resolved Hide resolved
@cessen
Copy link
Contributor

cessen commented Jun 20, 2021

To anyone watching: I got permission to take this PR over, so I'll be finishing this up.

@archseer archseer merged commit a70de6e into master Jun 22, 2021
@archseer archseer deleted the line_ending_detection branch June 22, 2021 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support CRLF Windows 10 build has malfunctioning view
3 participants