From 34a80c9f9b81b64d095a1d5123ae74a52bef4749 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 6 Nov 2026 12:42:32 -0300 Subject: idioms #17, the rest of the core says its failures: tagline, keys, panes, Effect and the header text in mouse report a failed allocation or shell where they returned with nothing said, the headers' own text (flatSurface makes none) and the prints whose buffer provably fits (layout, modal, panes, keys, colors) catch unreachable with why Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/tagline.zig | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/tagline.zig') diff --git a/src/tagline.zig b/src/tagline.zig index 28cd2a9b..a364732a 100644 --- a/src/tagline.zig +++ b/src/tagline.zig @@ -81,7 +81,7 @@ pub fn revealHeader(p: *Pardes) void { v.header_top = 0; return; }; - const text = edit.flatSurface(p, t) catch return; + const text = edit.flatSurface(p, t) catch unreachable; // a header's text is its own (flatSurface makes none) const cur: usize = @intCast(@max(0, t.cur_row)); const rows: usize = if (p.headerColumn() != null) layout.columnBarHeight(p) else p.topBarHeight(); if (cur < v.header_top) v.header_top = cur; @@ -211,7 +211,7 @@ pub fn tagText(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) ![]u8 { /// it starts on Save, so that `:` and the execute key write the file. pub fn enterTag(p: *Pardes, pane: *Pane) void { const t = &pane.tag; - const whole = tagText(p, p.scratch.allocator(), pane) catch return; + const whole = tagText(p, p.scratch.allocator(), pane) catch |err| return p.reportError(p.view().active, "tag", err); if (!t.cur_pinned) { // Save is looked for in the tag's own text, after the prefix. const lead = whole.len - curTail(pane).len; @@ -365,7 +365,7 @@ pub fn typedIntoName(p: *Pardes, pane: *Pane, key: pardes.Key) bool { pub fn draftName(p: *Pardes, pane: *Pane, col: usize) void { const f = pane.file orelse return; if (!panes.Output.fileTraits(f.output).saves) return; - const name = p.gpa.dupe(u8, f.path) catch return; + const name = p.gpa.dupe(u8, f.path) catch |err| return p.reportError(p.view().active, "name", err); pane.closePrompt(); pane.prompt = .name; pane.prompt_view = p.live; @@ -415,7 +415,7 @@ pub fn enterHeader(p: *Pardes, column: ?usize) void { p.view().header = if (column) |c| .{ .column = c } else .workspace; if (column) |c| p.setActiveColumn(c); const t = focusedHeader(p) orelse return exitHeader(p); - takeKeyboard(t, edit.flatSurface(p, t) catch ""); + takeKeyboard(t, edit.flatSurface(p, t) catch unreachable); // a header's text is its own } /// The span a header's selection covers on line `row` of its text, in @@ -443,7 +443,7 @@ pub fn workspaceBlank(p: *Pardes, col: u16, row: u16, tag_hit: ?pardes.TagHit) b const v = p.view(); if (row >= p.topBarHeight() or col >= v.screen_w) return false; if (col < TAG_TEXT_INSET) return true; - const text = edit.flatSurface(p, &p.global_tag) catch return false; + const text = edit.flatSurface(p, &p.global_tag) catch unreachable; // a header's text is its own const scroll: usize = if (v.header != null and p.headerColumn() == null) v.header_scroll else 0; const at = @as(usize, Layer.columnAt(p, .workspace, 0, tag_hit, false, 0) orelse (col - TAG_TEXT_INSET)) + scroll; return at >= panes.File.displayWidth(modal.lineSlice(text, 0)) + 2; -- cgit v1.3