refactor: make get_next_mru_buffer prefer buffers from current split

This commit is contained in:
CJ van den Berg 2026-01-14 20:30:32 +01:00
parent 51b2509f22
commit cf7c54aa63
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -1927,6 +1927,18 @@ fn get_next_mru_buffer(self: *Self, mode: enum { all, hidden, non_hidden }) ?[]c
const buffers = self.buffer_manager.list_most_recently_used(self.allocator) catch return null;
defer self.allocator.free(buffers);
const active_file_path = self.get_active_file_path();
for (buffers) |buffer| {
if (active_file_path) |fp| if (std.mem.eql(u8, fp, buffer.get_file_path()))
continue;
if (switch (mode) {
.all => false,
.hidden => !buffer.hidden,
.non_hidden => buffer.hidden,
}) continue;
if (buffer.get_last_view() != self.active_view)
continue;
return buffer.get_file_path();
}
for (buffers) |buffer| {
if (active_file_path) |fp| if (std.mem.eql(u8, fp, buffer.get_file_path()))
continue;