From 7c354c994ffad523f02fb4d961ea5092cffff883 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Fri, 21 Feb 2025 21:38:25 +0100 Subject: [PATCH 1/2] feat: improve shell_execute_stream_output to follow output tail only if cursor is at buffer end --- src/tui/editor.zig | 14 ++++++++++++++ src/tui/mainview.zig | 3 +-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/tui/editor.zig b/src/tui/editor.zig index 158c9d5..6fbad3b 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -3993,6 +3993,20 @@ pub const Editor = struct { } pub const smart_insert_line_after_meta = .{ .description = "Insert line after (smart)" }; + pub fn smart_buffer_append(self: *Self, ctx: Context) Result { + var chars: []const u8 = undefined; + if (!try ctx.args.match(.{tp.extract(&chars)})) + return error.InvalidInsertCharsArgument; + const b = try self.buf_for_update(); + var root = b.root; + var cursel: CurSel = .{}; + cursel.cursor.move_buffer_end(root, self.metrics); + root = try self.insert(root, &cursel, chars, b.allocator); + try self.update_buf(root); + self.clamp(); + } + pub const smart_buffer_append_meta = .{ .arguments = &.{.string} }; + pub fn enable_fast_scroll(self: *Self, _: Context) Result { self.fast_scroll = true; } diff --git a/src/tui/mainview.zig b/src/tui/mainview.zig index 98795f6..0bce784 100644 --- a/src/tui/mainview.zig +++ b/src/tui/mainview.zig @@ -847,8 +847,7 @@ const cmds = struct { return error.InvalidShellOutputArgument; const buffer = self.buffer_manager.buffer_from_ref(buffer_ref) orelse return; if (self.get_active_editor()) |editor| if (editor.buffer) |eb| if (eb == buffer) { - editor.move_buffer_end(.{}) catch {}; - editor.insert_chars(command.fmt(.{output})) catch {}; + editor.smart_buffer_append(command.fmt(.{output})) catch {}; tui.need_render(); return; }; From a288945609df08b6efefd980936ee3826c9575dc Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Fri, 21 Feb 2025 21:39:06 +0100 Subject: [PATCH 2/2] feat: toggle gutter symbols along with inline diagnostics --- src/tui/editor_gutter.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tui/editor_gutter.zig b/src/tui/editor_gutter.zig index 21297c0..9e80dbc 100644 --- a/src/tui/editor_gutter.zig +++ b/src/tui/editor_gutter.zig @@ -265,7 +265,8 @@ inline fn render_diff_symbols(self: *Self, diff_symbols: *[]Symbol, pos: usize, } fn render_diagnostics(self: *Self, theme: *const Widget.Theme) void { - for (self.editor.diagnostics.items) |*diag| self.render_diagnostic(diag, theme); + if (tui.config().inline_diagnostics) + for (self.editor.diagnostics.items) |*diag| self.render_diagnostic(diag, theme); } fn render_diagnostic(self: *Self, diag: *const ed.Diagnostic, theme: *const Widget.Theme) void {