on master help sign in
Don't need getters/setters for line_ending property.

It's plain-old-data. If we want to do fancier things later, it's easy to switch back.

commit714002048cc9601bf0981435c6d3ad43d1c765e8 authorNathan Vegdahl <cessen@cessen.com> dateMon 21 Jun 2021, 09:52 (5 years ago) parent3d3149e
2 files changed+5−13
helix-term/src/commands.rs+4−4 helix-view/src/document.rs+1−9
helix-term/src/commands.rs+4−4
@@ -1009,7 +1009,7 @@ fn append_mode(cx: &mut Context) {
10091009 if selection.iter().any(|range| range.head == end) {
10101010 let transaction = Transaction::change(
10111011 doc.text(),
1012− std::array::IntoIter::new([(end, end, Some(doc.line_ending().as_str().into()))]),
1012+ std::array::IntoIter::new([(end, end, Some(doc.line_ending.as_str().into()))]),
10131013 );
10141014 doc.apply(&transaction, view.id);
10151015 }
@@ -2349,7 +2349,7 @@ pub mod insert {
23492349 );
23502350 let indent = doc.indent_unit().repeat(indent_level);
23512351 let mut text = String::with_capacity(1 + indent.len());
2352− text.push_str(doc.line_ending().as_str());
2352+ text.push_str(doc.line_ending.as_str());
23532353 text.push_str(&indent);
23542354
23552355 let head = pos + offs + text.chars().count();
@@ -2370,7 +2370,7 @@ pub mod insert {
23702370 if helix_core::auto_pairs::PAIRS.contains(&(prev, curr)) {
23712371 // another newline, indent the end bracket one level less
23722372 let indent = doc.indent_unit().repeat(indent_level.saturating_sub(1));
2373− text.push_str(doc.line_ending().as_str());
2373+ text.push_str(doc.line_ending.as_str());
23742374 text.push_str(&indent);
23752375 }
23762376
@@ -2537,7 +2537,7 @@ fn paste_impl(
25372537 // if any of values ends \n it's linewise paste
25382538 let linewise = values
25392539 .iter()
2540− .any(|value| value.ends_with(doc.line_ending().as_str()));
2540+ .any(|value| value.ends_with(doc.line_ending.as_str()));
25412541
25422542 let mut values = values.iter().cloned().map(Tendril::from).chain(repeat);
25432543
helix-view/src/document.rs+1−9
@@ -268,7 +268,7 @@ impl Document {
268268 // set the path and try detecting the language
269269 doc.set_path(&path)?;
270270 doc.detect_indent_style();
271− doc.set_line_ending(line_ending);
271+ doc.line_ending = line_ending;
272272
273273 if let Some(loader) = config_loader {
274274 doc.detect_language(theme, loader);
@@ -531,10 +531,6 @@ impl Document {
531531 self.selections.insert(view_id, selection);
532532 }
533533
534− pub fn set_line_ending(&mut self, line_ending: LineEnding) {
535− self.line_ending = line_ending;
536− }
537−
538534 fn _apply(&mut self, transaction: &Transaction, view_id: ViewId) -> bool {
539535 let old_doc = self.text().clone();
540536
@@ -805,10 +801,6 @@ impl Document {
805801 pub fn set_diagnostics(&mut self, diagnostics: Vec<Diagnostic>) {
806802 self.diagnostics = diagnostics;
807803 }
808−
809− pub fn line_ending(&self) -> LineEnding {
810− self.line_ending
811− }
812804}
813805
814806#[cfg(test)]