diff options
author | Jan Hrastnik | 2021-06-13 19:38:31 +0000 |
---|---|---|
committer | Jan Hrastnik | 2021-06-16 15:11:16 +0000 |
commit | a9a718c3cad3af7b9fa38cd1aaa6ceb6c7126130 (patch) | |
tree | d44d55189b0fa666aebf592724ee3bff52e3f63c /helix-view/src | |
parent | e4849f41beb2d35a4833a8b7de717b4f38b3f270 (diff) |
added some tests and a line_ending helper function in document.rs
Diffstat (limited to 'helix-view/src')
-rw-r--r-- | helix-view/src/document.rs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index 704094a6..bd5f8012 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -6,9 +6,9 @@ use std::sync::Arc; use helix_core::{ chars::{char_is_linebreak, char_is_whitespace}, - auto_detect_line_ending, DEFAULT_LINE_ENDING, history::History, syntax::{LanguageConfiguration, LOADER}, ChangeSet, Diagnostic, LineEnding, Rope, Selection, State, Syntax, Transaction, + DEFAULT_LINE_ENDING, }; use crate::{DocumentId, ViewId}; @@ -740,6 +740,20 @@ impl Document { pub fn set_diagnostics(&mut self, diagnostics: Vec<Diagnostic>) { self.diagnostics = diagnostics; } + + pub fn line_ending(&self) -> &str { + match self.line_ending { + LineEnding::Crlf => "\u{000D}\u{000A}", + LineEnding::LF => "\u{000A}", + LineEnding::Nel => "\u{0085}", + LineEnding::LS => "\u{2028}", + LineEnding::CR => "\u{000D}", + _ => panic!( + "Unexpected line ending: {:?}, expected Crlf, LF, CR, Nel, or LS.", + self.line_ending + ), + } + } } #[cfg(test)] |