summaryrefslogtreecommitdiff
path: root/src/modal.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-01 18:07:32 -0300
committerGabriel Schneider <[email protected]>2026-10-01 19:57:27 -0300
commit6ee4c3caa6faf42b9825dca39e9130ac83f425a8 (patch)
tree65b92aa4faa3161ee507a66c6d755186681541a0 /src/modal.zig
parent7f748c657121c801f219b28680373729fefce82a (diff)
downloadpardes-6ee4c3caa6faf42b9825dca39e9130ac83f425a8.tar.gz
pardes-6ee4c3caa6faf42b9825dca39e9130ac83f425a8.zip
Enter, o and O give the new line the old one's indent as it is, tabs and all, as acme's autoindent does; a level more after an opening delimiter is a tab where the indent is tabs
The indent was rebuilt as spaces, partial levels dropped, so a tab-indented line went on with spaces (or with one space, after Enter). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/modal.zig')
-rw-r--r--src/modal.zig8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/modal.zig b/src/modal.zig
index 11eda7b9..316a66fa 100644
--- a/src/modal.zig
+++ b/src/modal.zig
@@ -1773,12 +1773,10 @@ pub fn indentWidth(line: []const u8) usize {
return w;
}
-/// full indent LEVELS of a line as spaces (helix indent_level_for_line:
-/// partial levels round down) — what o/O/insert-newline copy.
+/// A line's indent as it is, tabs and spaces both, as acme's autoindent
+/// copies it: what o/O/insert-newline give the new line.
pub fn indentText(line: []const u8) []const u8 {
- const level = indentWidth(line) / INDENT_W;
- const max = " "; // 8 levels is plenty (ponytail)
- return max[0..@min(level * INDENT_W, max.len)];
+ return line[0 .. std.mem.indexOfNone(u8, line, " \t") orelse line.len];
}
/// Copy full indent levels and add one after (, [, {, or ), without parsing.