feat: add restore_last_cursor_position_exclusions config option

Defaults to just COMMIT_EDITMSG
This commit is contained in:
CJ van den Berg 2026-04-03 18:03:45 +02:00
parent cf7fc6af54
commit 51753cc87a
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
2 changed files with 9 additions and 0 deletions

View file

@ -34,6 +34,7 @@ idle_actions: []const IdleAction = &default_actions,
idle_commands: ?[]const []const u8 = null, // a list of simple commands
enable_format_on_save: bool = false,
restore_last_cursor_position: bool = true,
restore_last_cursor_position_exclusions: []const []const u8 = &.{"COMMIT_EDITMSG"},
follow_cursor_on_buffer_switch: bool = false, //scroll cursor into view on buffer switch
default_cursor: CursorShape = .default,
modes_can_change_cursor: bool = true,

View file

@ -559,7 +559,15 @@ const cmds = struct {
const view = self.get_view_for_file(f);
const have_editor_metadata = if (self.buffer_manager.get_buffer_for_file(f)) |_| true else false;
const basename = std.fs.path.basename(f);
var is_excluded = false;
for (tui.config().restore_last_cursor_position_exclusions) |exclusion| if (std.mem.eql(u8, basename, exclusion)) {
is_excluded = true;
break;
};
if (tui.config().restore_last_cursor_position and
!is_excluded and
view == null and
!have_editor_metadata and
line == null and