@@ -138,3 +138,20 @@ pub fn temp_file_with_contents<S: AsRef<str>>(
138 temp_file.as_file_mut().sync_all()?;
138 temp_file.as_file_mut().sync_all()?;
139 Ok(temp_file)
139 Ok(temp_file)
142+/// Replaces all LF chars with the system's appropriate line feed
143+/// character, and if one doesn't exist already, appends the system's
144+/// appropriate line ending to the end of a string.
145+pub fn platform_line(input: &str) -> String {
146+ let line_end = helix_core::DEFAULT_LINE_ENDING.as_str();
148+ // we can assume that the source files in this code base will always
149+ // be LF, so indoc strings will always insert LF
150+ let mut output = input.replace("\n", line_end);
152+ if !output.ends_with(line_end) {
153+ output.push_str(line_end);