From ef8fe5a5ce536c65f34e479db79b94c8435aa3b2 Mon Sep 17 00:00:00 2001 From: Skyler Hawthorne Date: Fri, 29 Apr 2022 16:27:35 -0400 Subject: use system's appropriate line ending --- helix-term/tests/integration/helpers.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'helix-term/tests/integration/helpers.rs') diff --git a/helix-term/tests/integration/helpers.rs b/helix-term/tests/integration/helpers.rs index 2a542404..706e1afb 100644 --- a/helix-term/tests/integration/helpers.rs +++ b/helix-term/tests/integration/helpers.rs @@ -138,3 +138,20 @@ pub fn temp_file_with_contents>( temp_file.as_file_mut().sync_all()?; Ok(temp_file) } + +/// Replaces all LF chars with the system's appropriate line feed +/// 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(); + + // we can assume that the source files in this code base will always + // be LF, so indoc strings will always insert LF + let mut output = input.replace("\n", line_end); + + if !output.ends_with(line_end) { + output.push_str(line_end); + } + + output +} -- cgit v1.2.3-70-g09d2