feat: add show_diagnostics command and bind it to C-S-m and diagstate.on_click
This commit is contained in:
parent
a71a8cfc6e
commit
f9c029f617
3 changed files with 19 additions and 1 deletions
|
@ -456,6 +456,22 @@ const cmds = struct {
|
|||
if (self.file_list_type == .diagnostics and self.is_panel_view_showing(filelist_view))
|
||||
try self.toggle_panel_view(filelist_view, false);
|
||||
}
|
||||
|
||||
pub fn show_diagnostics(self: *Self, _: Ctx) Result {
|
||||
const editor = self.editor orelse return;
|
||||
for (editor.diagnostics.items) |diagnostic| {
|
||||
try self.add_find_in_files_result(
|
||||
.diagnostics,
|
||||
editor.file_path orelse "",
|
||||
diagnostic.sel.begin.row + 1,
|
||||
diagnostic.sel.begin.col,
|
||||
diagnostic.sel.end.row + 1,
|
||||
diagnostic.sel.end.col,
|
||||
diagnostic.message,
|
||||
ed.Diagnostic.to_severity(diagnostic.severity),
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
pub fn handle_editor_event(self: *Self, _: tp.pid_ref, m: tp.message) tp.result {
|
||||
|
|
|
@ -129,6 +129,7 @@ fn mapPress(self: *Self, keypress: u32, egc: u32, modifiers: u32) !void {
|
|||
'F' => self.cmd("enter_find_in_files_mode", .{}),
|
||||
'L' => self.cmd_async("add_cursor_all_matches"),
|
||||
'I' => self.cmd_async("toggle_inspector_view"),
|
||||
'M' => self.cmd("show_diagnostics", .{}),
|
||||
key.ENTER => self.cmd("smart_insert_line_before", .{}),
|
||||
key.END => self.cmd("select_buffer_end", .{}),
|
||||
key.HOME => self.cmd("select_buffer_begin", .{}),
|
||||
|
@ -396,6 +397,7 @@ const hints = tui.KeybindHints.initComptime(.{
|
|||
.{ "select_up", "S-up" },
|
||||
.{ "select_word_left", "C-S-left" },
|
||||
.{ "select_word_right", "C-S-right" },
|
||||
.{ "show_diagnostics", "C-S-m" },
|
||||
.{ "smart_insert_line_after", "C-enter" },
|
||||
.{ "smart_insert_line_before", "S-enter, C-S-enter" },
|
||||
.{ "smart_insert_line", "enter" },
|
||||
|
|
|
@ -32,7 +32,7 @@ pub fn create(a: Allocator, parent: Plane, event_handler: ?Widget.EventHandler)
|
|||
}
|
||||
|
||||
fn on_click(_: *Self, _: *Button.State(Self)) void {
|
||||
command.executeName("goto_next_diagnostic", .{}) catch {};
|
||||
command.executeName("show_diagnostics", .{}) catch {};
|
||||
}
|
||||
|
||||
pub fn layout(self: *Self, _: *Button.State(Self)) Widget.Layout {
|
||||
|
|
Loading…
Add table
Reference in a new issue