aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorTriton1712023-02-16 14:47:59 +0000
committerGitHub2023-02-16 14:47:59 +0000
commita1a6d5f3340ba8a587bbf8c178fe65589f36a51a (patch)
treed4dc784d6e4e02e2ee4f6578734869f4e92098c0 /helix-term
parentd27e808fb3565d59b3082e4ce0bc8e381a03e16e (diff)
Replace incorrect usages of tab_width with indent_width. (#5918)
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/commands.rs19
1 files changed, 6 insertions, 13 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index a3c9f0b4..fb55ca2a 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -3364,8 +3364,8 @@ pub mod insert {
let count = cx.count();
let (view, doc) = current_ref!(cx.editor);
let text = doc.text().slice(..);
- let indent_unit = doc.indent_style.as_str();
- let tab_size = doc.tab_width();
+ let tab_width = doc.tab_width();
+ let indent_width = doc.indent_width();
let auto_pairs = doc.auto_pairs(cx.editor);
let transaction =
@@ -3386,18 +3386,11 @@ pub mod insert {
None,
)
} else {
- let unit_len = indent_unit.chars().count();
- // NOTE: indent_unit always contains 'only spaces' or 'only tab' according to `IndentStyle` definition.
- let unit_size = if indent_unit.starts_with('\t') {
- tab_size * unit_len
- } else {
- unit_len
- };
let width: usize = fragment
.chars()
.map(|ch| {
if ch == '\t' {
- tab_size
+ tab_width
} else {
// it can be none if it still meet control characters other than '\t'
// here just set the width to 1 (or some value better?).
@@ -3405,9 +3398,9 @@ pub mod insert {
}
})
.sum();
- let mut drop = width % unit_size; // round down to nearest unit
+ let mut drop = width % indent_width; // round down to nearest unit
if drop == 0 {
- drop = unit_size
+ drop = indent_width
}; // if it's already at a unit, consume a whole unit
let mut chars = fragment.chars().rev();
let mut start = pos;
@@ -3949,7 +3942,7 @@ fn unindent(cx: &mut Context) {
let lines = get_lines(doc, view.id);
let mut changes = Vec::with_capacity(lines.len());
let tab_width = doc.tab_width();
- let indent_width = count * tab_width;
+ let indent_width = count * doc.indent_width();
for line_idx in lines {
let line = doc.text().line(line_idx);