fix: only fallback to get_next_file in get_next_diagnostic if it is available

This commit is contained in:
CJ van den Berg 2024-08-27 19:16:08 +02:00
parent 32f00daf76
commit 70ec2a11c5
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -3320,7 +3320,11 @@ pub const Editor = struct {
} }
pub fn goto_next_diagnostic(self: *Self, _: Context) Result { pub fn goto_next_diagnostic(self: *Self, _: Context) Result {
if (self.diagnostics.items.len == 0) return command.executeName("goto_next_file", .{}); if (self.diagnostics.items.len == 0) {
if (command.getId("goto_next_file")) |id|
return command.execute(id, .{});
return;
}
self.sort_diagnostics(); self.sort_diagnostics();
const primary = self.get_primary(); const primary = self.get_primary();
for (self.diagnostics.items) |*diag| { for (self.diagnostics.items) |*diag| {
@ -3331,7 +3335,11 @@ pub const Editor = struct {
} }
pub fn goto_prev_diagnostic(self: *Self, _: Context) Result { pub fn goto_prev_diagnostic(self: *Self, _: Context) Result {
if (self.diagnostics.items.len == 0) return command.executeName("goto_prev_file", .{}); if (self.diagnostics.items.len == 0) {
if (command.getId("goto_prev_file")) |id|
return command.execute(id, .{});
return;
}
self.sort_diagnostics(); self.sort_diagnostics();
const primary = self.get_primary(); const primary = self.get_primary();
var i = self.diagnostics.items.len - 1; var i = self.diagnostics.items.len - 1;