From 6ee4c3caa6faf42b9825dca39e9130ac83f425a8 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 1 Oct 2026 18:07:32 -0300 Subject: 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 --- src/modal.zig | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/modal.zig') 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. -- cgit v1.3