aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/commands.rs28
-rw-r--r--helix-term/src/health.rs2
2 files changed, 13 insertions, 17 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 4b4e834a..bd66f26a 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -2240,17 +2240,16 @@ fn open(cx: &mut Context, open: Open) {
)
};
- // TODO: share logic with insert_newline for indentation
- let indent_level = indent::suggested_indent_for_pos(
+ let indent = indent::indent_for_newline(
doc.language_config(),
doc.syntax(),
+ &doc.indent_style,
+ doc.tab_width(),
text,
- line_end_index,
new_line.saturating_sub(1),
- true,
- )
- .unwrap_or_else(|| indent::indent_level_for_line(text.line(cursor_line), doc.tab_width()));
- let indent = doc.indent_unit().repeat(indent_level);
+ line_end_index,
+ cursor_line,
+ );
let indent_len = indent.len();
let mut text = String::with_capacity(1 + indent_len);
text.push_str(doc.line_ending.as_str());
@@ -2703,19 +2702,16 @@ pub mod insert {
let curr = contents.get_char(pos).unwrap_or(' ');
let current_line = text.char_to_line(pos);
- let indent_level = indent::suggested_indent_for_pos(
+ let indent = indent::indent_for_newline(
doc.language_config(),
doc.syntax(),
+ &doc.indent_style,
+ doc.tab_width(),
text,
+ current_line,
pos,
current_line,
- true,
- )
- .unwrap_or_else(|| {
- indent::indent_level_for_line(text.line(current_line), doc.tab_width())
- });
-
- let indent = doc.indent_unit().repeat(indent_level);
+ );
let mut text = String::new();
// If we are between pairs (such as brackets), we want to
// insert an additional line which is indented one level
@@ -2727,7 +2723,7 @@ pub mod insert {
.is_some();
let new_head_pos = if on_auto_pair {
- let inner_indent = doc.indent_unit().repeat(indent_level + 1);
+ let inner_indent = indent.clone() + doc.indent_style.as_str();
text.reserve_exact(2 + indent.len() + inner_indent.len());
text.push_str(doc.line_ending.as_str());
text.push_str(&inner_indent);
diff --git a/helix-term/src/health.rs b/helix-term/src/health.rs
index 80f59680..f73139fc 100644
--- a/helix-term/src/health.rs
+++ b/helix-term/src/health.rs
@@ -19,7 +19,7 @@ impl TsFeature {
match *self {
Self::Highlight => "highlights.scm",
Self::TextObject => "textobjects.scm",
- Self::AutoIndent => "indents.toml",
+ Self::AutoIndent => "indents.scm",
}
}