From 993add1a4319cce5165bdc8f7a5fdd651d77daa2 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Mon, 28 Apr 2025 11:02:54 +0200 Subject: [PATCH] feat: add restore_last_cursor_position config option (default true) --- src/config.zig | 1 + src/tui/mainview.zig | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/config.zig b/src/config.zig index ec0e51d..05dc404 100644 --- a/src/config.zig +++ b/src/config.zig @@ -17,6 +17,7 @@ inline_diagnostics: bool = true, animation_min_lag: usize = 0, //milliseconds animation_max_lag: usize = 150, //milliseconds enable_format_on_save: bool = false, +restore_last_cursor_position: bool = true, default_cursor: []const u8 = "default", indent_size: usize = 4, diff --git a/src/tui/mainview.zig b/src/tui/mainview.zig index 7d68dcb..b68e273 100644 --- a/src/tui/mainview.zig +++ b/src/tui/mainview.zig @@ -384,7 +384,11 @@ const cmds = struct { const same_file = if (self.get_active_file_path()) |fp| std.mem.eql(u8, fp, f) else false; const have_editor_metadata = if (self.buffer_manager.get_buffer_for_file(f)) |_| true else false; - if (!same_file and !have_editor_metadata and line == null) { + if (tui.config().restore_last_cursor_position and + !same_file and + !have_editor_metadata and + line == null) + { const ctx_: struct { allocator: std.mem.Allocator, from: tp.pid,