From 6bb6141ef3fe3c10b657246d0772a84f3b8b4d80 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Wed, 10 Dec 2025 12:27:58 +0100 Subject: [PATCH] fix: avoid resetting cursors and matches if formatter makes no changes --- src/tui/editor.zig | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/tui/editor.zig b/src/tui/editor.zig index 39fb611..8bcdfde 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -6278,8 +6278,6 @@ pub const Editor = struct { if (state.before_root != root) return error.Stop; defer self.filter_deinit(); const primary = self.get_primary(); - self.cancel_all_selections(); - self.cancel_all_matches(); if (state.whole_file) |buf| { if (buf.items.len == 0) { self.logger.print_err("filter", "empty filter result", .{}); @@ -6295,12 +6293,16 @@ pub const Editor = struct { if (old_hash == new_hash) { state.no_changes = true; } else { + self.cancel_all_selections(); + self.cancel_all_matches(); state.work_root = try b.load_from_string(buf.items, &state.eol_mode, &state.utf8_sanitized); state.bytes = buf.items.len; state.chunks = 1; primary.cursor = state.old_primary.cursor; } } else { + self.cancel_all_selections(); + self.cancel_all_matches(); const sel = primary.enable_selection(root, self.metrics); sel.begin = state.begin; sel.end = state.pos.cursor;