Merge pull request #733 from mitchellh/insp-crash

Fix inspector toggle crash, default keybinds to match Chromium
This commit is contained in:
Mitchell Hashimoto
2023-10-26 14:44:47 -07:00
committed by GitHub
2 changed files with 23 additions and 2 deletions

View File

@ -1014,8 +1014,15 @@ pub fn keyCallback(
// When we're done processing, we always want to add the event to // When we're done processing, we always want to add the event to
// the inspector. // the inspector.
defer if (insp_ev) |ev| { defer if (insp_ev) |ev| ev: {
if (self.inspector.?.recordKeyEvent(ev)) { // We have to check for the inspector again because our keybinding
// might close it.
const insp = self.inspector orelse {
ev.deinit(self.alloc);
break :ev;
};
if (insp.recordKeyEvent(ev)) {
self.queueRender() catch {}; self.queueRender() catch {};
} else |err| { } else |err| {
log.warn("error adding key event to inspector err={}", .{err}); log.warn("error adding key event to inspector err={}", .{err});

View File

@ -753,6 +753,13 @@ pub fn default(alloc_gpa: Allocator) Allocator.Error!Config {
.{ .key = .page_down, .mods = .{ .shift = true, .ctrl = true } }, .{ .key = .page_down, .mods = .{ .shift = true, .ctrl = true } },
.{ .jump_to_prompt = 1 }, .{ .jump_to_prompt = 1 },
); );
// Inspector, matching Chromium
try result.keybind.set.put(
alloc,
.{ .key = .i, .mods = .{ .shift = true, .ctrl = true } },
.{ .inspector = .toggle },
);
} }
{ {
// Cmd+N for goto tab N // Cmd+N for goto tab N
@ -913,6 +920,13 @@ pub fn default(alloc_gpa: Allocator) Allocator.Error!Config {
.{ .key = .right, .mods = .{ .super = true, .alt = true } }, .{ .key = .right, .mods = .{ .super = true, .alt = true } },
.{ .goto_split = .right }, .{ .goto_split = .right },
); );
// Inspector, matching Chromium
try result.keybind.set.put(
alloc,
.{ .key = .i, .mods = .{ .alt = true, .super = true } },
.{ .inspector = .toggle },
);
} }
return result; return result;