on master help sign in
chore(view): remove indent_unit helper fn (#4389)
4cff625Matouš Dzivjak
helix-term/src/commands.rs+3−3
@@ -3022,7 +3022,7 @@ pub mod insert {
3022 // TODO: round out to nearest indentation level (for example a line with 3 spaces should
3022 // TODO: round out to nearest indentation level (for example a line with 3 spaces should
3023 // indent by one to reach 4 spaces).
3023 // indent by one to reach 4 spaces).
3024
3024
3025− let indent = Tendril::from(doc.indent_unit());
3025+ let indent = Tendril::from(doc.indent_style.as_str());
3026 let transaction = Transaction::insert(
3026 let transaction = Transaction::insert(
3027 doc.text(),
3027 doc.text(),
3028 &doc.selection(view.id).clone().cursors(doc.text().slice(..)),
3028 &doc.selection(view.id).clone().cursors(doc.text().slice(..)),
@@ -3122,7 +3122,7 @@ pub mod insert {
3122 let count = cx.count();
3122 let count = cx.count();
3123 let (view, doc) = current_ref!(cx.editor);
3123 let (view, doc) = current_ref!(cx.editor);
3124 let text = doc.text().slice(..);
3124 let text = doc.text().slice(..);
3125− let indent_unit = doc.indent_unit();
3125+ let indent_unit = doc.indent_style.as_str();
3126 let tab_size = doc.tab_width();
3126 let tab_size = doc.tab_width();
3127 let auto_pairs = doc.auto_pairs(cx.editor);
3127 let auto_pairs = doc.auto_pairs(cx.editor);
3128
3128
@@ -3647,7 +3647,7 @@ fn indent(cx: &mut Context) {
3647 let lines = get_lines(doc, view.id);
3647 let lines = get_lines(doc, view.id);
3648
3648
3649 // Indent by one level
3649 // Indent by one level
3650− let indent = Tendril::from(doc.indent_unit().repeat(count));
3650+ let indent = Tendril::from(doc.indent_style.as_str().repeat(count));
3651
3651
3652 let transaction = Transaction::change(
3652 let transaction = Transaction::change(
3653 doc.text(),
3653 doc.text(),
helix-view/src/document.rs−8
@@ -1052,14 +1052,6 @@ impl Document {
1052 .map_or(4, |config| config.tab_width) // fallback to 4 columns
1052 .map_or(4, |config| config.tab_width) // fallback to 4 columns
1053 }
1053 }
1054
1054
1055− /// Returns a string containing a single level of indentation.
1056− ///
1057− /// TODO: we might not need this function anymore, since the information
1058− /// is conveniently available in `Document::indent_style` now.
1059− pub fn indent_unit(&self) -> &'static str {
1060− self.indent_style.as_str()
1061− }
1062−
1063 pub fn changes(&self) -> &ChangeSet {
1055 pub fn changes(&self) -> &ChangeSet {
1064 &self.changes
1056 &self.changes
1065 }
1057 }