diff --git a/helix-core/src/line_ending.rs b/helix-core/src/line_ending.rs index 8c33fcdbbd1c3..b534e179ac4a1 100644 --- a/helix-core/src/line_ending.rs +++ b/helix-core/src/line_ending.rs @@ -112,7 +112,7 @@ impl LineEnding { /// /// [`LineEnding::Crlf`] on Windows, otherwise [`LineEnding::LF`]. #[inline] - pub fn native() -> Self { + pub const fn native() -> Self { #[cfg(target_os = "windows")] return LineEnding::Crlf; #[cfg(not(target_os = "windows"))] diff --git a/helix-term/tests/test/auto_pairs.rs b/helix-term/tests/test/auto_pairs.rs index e18c71195fb49..40d687f3e18a8 100644 --- a/helix-term/tests/test/auto_pairs.rs +++ b/helix-term/tests/test/auto_pairs.rs @@ -2,7 +2,7 @@ use helix_core::{auto_pairs::DEFAULT_PAIRS, hashmap}; use super::*; -const LINE_END: &str = helix_core::DEFAULT_LINE_ENDING.as_str(); +const LINE_END: &str = helix_core::LineEnding::native().as_str(); fn differing_pairs() -> impl Iterator { DEFAULT_PAIRS.iter().filter(|(open, close)| open != close) diff --git a/helix-term/tests/test/helpers.rs b/helix-term/tests/test/helpers.rs index a0f3a32e4cba3..406d817e6d064 100644 --- a/helix-term/tests/test/helpers.rs +++ b/helix-term/tests/test/helpers.rs @@ -230,7 +230,7 @@ pub fn temp_file_with_contents>( /// character, and if one doesn't exist already, appends the system's /// appropriate line ending to the end of a string. pub fn platform_line(input: &str) -> String { - let line_end = helix_core::DEFAULT_LINE_ENDING.as_str(); + let line_end = helix_core::LineEnding::native().as_str(); // we can assume that the source files in this code base will always // be LF, so indoc strings will always insert LF diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index 73dd4f6187e92..4b476d813215e 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -1391,9 +1391,10 @@ mod test { #[test] fn test_line_ending() { + let line_ending = LineEnding::native(); assert_eq!( - Document::default().text().to_string(), - DEFAULT_LINE_ENDING.as_str() + Document::new(line_ending).text().to_string(), + line_ending.as_str() ); } diff --git a/helix-view/src/gutter.rs b/helix-view/src/gutter.rs index c1b5e2b161126..6ec2e010de1ef 100644 --- a/helix-view/src/gutter.rs +++ b/helix-view/src/gutter.rs @@ -296,7 +296,7 @@ mod tests { use crate::editor::{GutterConfig, GutterLineNumbersConfig}; use crate::graphics::Rect; use crate::DocumentId; - use helix_core::Rope; + use helix_core::{LineEnding, Rope}; #[test] fn test_default_gutter_widths() { @@ -304,7 +304,7 @@ mod tests { view.area = Rect::new(40, 40, 40, 40); let rope = Rope::from_str("abc\n\tdef"); - let doc = Document::from(rope, None); + let doc = Document::from(rope, None, LineEnding::native()); assert_eq!(view.gutters.layout.len(), 5); assert_eq!(view.gutters.layout[0].width(&view, &doc), 1); @@ -325,7 +325,7 @@ mod tests { view.area = Rect::new(40, 40, 40, 40); let rope = Rope::from_str("abc\n\tdef"); - let doc = Document::from(rope, None); + let doc = Document::from(rope, None, LineEnding::native()); assert_eq!(view.gutters.layout.len(), 1); assert_eq!(view.gutters.layout[0].width(&view, &doc), 1); @@ -339,7 +339,7 @@ mod tests { view.area = Rect::new(40, 40, 40, 40); let rope = Rope::from_str("abc\n\tdef"); - let doc = Document::from(rope, None); + let doc = Document::from(rope, None, LineEnding::native()); assert_eq!(view.gutters.layout.len(), 2); assert_eq!(view.gutters.layout[0].width(&view, &doc), 1); @@ -357,10 +357,10 @@ mod tests { view.area = Rect::new(40, 40, 40, 40); let rope = Rope::from_str("a\nb"); - let doc_short = Document::from(rope, None); + let doc_short = Document::from(rope, None, LineEnding::native()); let rope = Rope::from_str("a\nb\nc\nd\ne\nf\ng\nh\ni\nj\nk\nl\nm\nn\no\np"); - let doc_long = Document::from(rope, None); + let doc_long = Document::from(rope, None, LineEnding::native()); assert_eq!(view.gutters.layout.len(), 2); assert_eq!(view.gutters.layout[1].width(&view, &doc_short), 1);