aboutsummaryrefslogtreecommitdiff
path: root/helix-core
diff options
context:
space:
mode:
authorJan Hrastnik2021-06-14 13:09:54 +0000
committerJan Hrastnik2021-06-16 15:13:41 +0000
commita4f5a0134e308ffad318ab6920fe1ed0264a93cb (patch)
treeae7ffa85fd3413e0fafc53443c98d6ddae34149c /helix-core
parenta9a718c3cad3af7b9fa38cd1aaa6ceb6c7126130 (diff)
trying out line ending helper functions in commands.rs
Diffstat (limited to 'helix-core')
-rw-r--r--helix-core/src/lib.rs4
-rw-r--r--helix-core/src/line_ending.rs8
2 files changed, 10 insertions, 2 deletions
diff --git a/helix-core/src/lib.rs b/helix-core/src/lib.rs
index 35124069..55365500 100644
--- a/helix-core/src/lib.rs
+++ b/helix-core/src/lib.rs
@@ -110,5 +110,7 @@ pub use syntax::Syntax;
pub use diagnostic::Diagnostic;
pub use state::State;
-pub use line_ending::{auto_detect_line_ending, LineEnding, DEFAULT_LINE_ENDING};
+pub use line_ending::{
+ auto_detect_line_ending, rope_slice_to_line_ending, LineEnding, DEFAULT_LINE_ENDING,
+};
pub use transaction::{Assoc, Change, ChangeSet, Operation, Transaction};
diff --git a/helix-core/src/line_ending.rs b/helix-core/src/line_ending.rs
index 47420f9e..4f5708ec 100644
--- a/helix-core/src/line_ending.rs
+++ b/helix-core/src/line_ending.rs
@@ -31,6 +31,9 @@ pub fn str_to_line_ending(g: &str) -> Option<LineEnding> {
"\u{000D}" => Some(LineEnding::CR),
"\u{0085}" => Some(LineEnding::Nel),
"\u{2028}" => Some(LineEnding::LS),
+ "\u{000B}" => Some(LineEnding::VT),
+ "\u{000C}" => Some(LineEnding::FF),
+ "\u{2029}" => Some(LineEnding::PS),
// Not a line ending
_ => None,
}
@@ -58,7 +61,10 @@ pub fn auto_detect_line_ending(doc: &Rope) -> Option<LineEnding> {
_ => None,
};
if ending.is_some() {
- return ending;
+ match ending {
+ Some(LineEnding::VT) | Some(LineEnding::FF) | Some(LineEnding::PS) => {}
+ _ => return ending,
+ }
}
}
ending