on master help sign in
Don't need getters/setters for line_ending property.
7140020Nathan Vegdahl
helix-term/src/commands.rs+4−4
@@ -1009,7 +1009,7 @@ fn append_mode(cx: &mut Context) {
1009 if selection.iter().any(|range| range.head == end) {
1009 if selection.iter().any(|range| range.head == end) {
1010 let transaction = Transaction::change(
1010 let transaction = Transaction::change(
1011 doc.text(),
1011 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()))]),
1013 );
1013 );
1014 doc.apply(&transaction, view.id);
1014 doc.apply(&transaction, view.id);
1015 }
1015 }
@@ -2349,7 +2349,7 @@ pub mod insert {
2349 );
2349 );
2350 let indent = doc.indent_unit().repeat(indent_level);
2350 let indent = doc.indent_unit().repeat(indent_level);
2351 let mut text = String::with_capacity(1 + indent.len());
2351 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());
2353 text.push_str(&indent);
2353 text.push_str(&indent);
2354
2354
2355 let head = pos + offs + text.chars().count();
2355 let head = pos + offs + text.chars().count();
@@ -2370,7 +2370,7 @@ pub mod insert {
2370 if helix_core::auto_pairs::PAIRS.contains(&(prev, curr)) {
2370 if helix_core::auto_pairs::PAIRS.contains(&(prev, curr)) {
2371 // another newline, indent the end bracket one level less
2371 // another newline, indent the end bracket one level less
2372 let indent = doc.indent_unit().repeat(indent_level.saturating_sub(1));
2372 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());
2374 text.push_str(&indent);
2374 text.push_str(&indent);
2375 }
2375 }
2376
2376
@@ -2537,7 +2537,7 @@ fn paste_impl(
2537 // if any of values ends \n it's linewise paste
2537 // if any of values ends \n it's linewise paste
2538 let linewise = values
2538 let linewise = values
2539 .iter()
2539 .iter()
2540− .any(|value| value.ends_with(doc.line_ending().as_str()));
2540+ .any(|value| value.ends_with(doc.line_ending.as_str()));
2541
2541
2542 let mut values = values.iter().cloned().map(Tendril::from).chain(repeat);
2542 let mut values = values.iter().cloned().map(Tendril::from).chain(repeat);
2543
2543
helix-view/src/document.rs+1−9
@@ -268,7 +268,7 @@ impl Document {
268 // set the path and try detecting the language
268 // set the path and try detecting the language
269 doc.set_path(&path)?;
269 doc.set_path(&path)?;
270 doc.detect_indent_style();
270 doc.detect_indent_style();
271− doc.set_line_ending(line_ending);
271+ doc.line_ending = line_ending;
272
272
273 if let Some(loader) = config_loader {
273 if let Some(loader) = config_loader {
274 doc.detect_language(theme, loader);
274 doc.detect_language(theme, loader);
@@ -531,10 +531,6 @@ impl Document {
531 self.selections.insert(view_id, selection);
531 self.selections.insert(view_id, selection);
532 }
532 }
533
533
534− pub fn set_line_ending(&mut self, line_ending: LineEnding) {
535− self.line_ending = line_ending;
536− }
537−
538 fn _apply(&mut self, transaction: &Transaction, view_id: ViewId) -> bool {
534 fn _apply(&mut self, transaction: &Transaction, view_id: ViewId) -> bool {
539 let old_doc = self.text().clone();
535 let old_doc = self.text().clone();
540
536
@@ -805,10 +801,6 @@ impl Document {
805 pub fn set_diagnostics(&mut self, diagnostics: Vec<Diagnostic>) {
801 pub fn set_diagnostics(&mut self, diagnostics: Vec<Diagnostic>) {
806 self.diagnostics = diagnostics;
802 self.diagnostics = diagnostics;
807 }
803 }
808−
809− pub fn line_ending(&self) -> LineEnding {
810− self.line_ending
811− }
812}
804}
813
805
814#[cfg(test)]
806#[cfg(test)]