summaryrefslogtreecommitdiff
path: root/src/builtins.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/builtins.zig')
-rw-r--r--src/builtins.zig37
1 files changed, 24 insertions, 13 deletions
diff --git a/src/builtins.zig b/src/builtins.zig
index b0499dc0..8788e65f 100644
--- a/src/builtins.zig
+++ b/src/builtins.zig
@@ -536,13 +536,18 @@ fn warnModifiedIn(c: Ctx, asking: Pane.Discarding, which: Asked) bool {
// under 100 bytes it is not asked about, as acme's winclean does not
// whine about a small unnamed window, nor about a command's output.
const scratch = if (f.output) |o| o.from == .cmd and o.from.cmd == .New else false;
- if (f.revision == f.saved_revision or !(panes.Output.fileTraits(f.output).saves or scratch)) continue;
- if (f.output != null and f.content.len < 100) continue;
- // Dirty by a rename alone is no text to lose, as get says (ctl.zig).
- // Nor is a buffer never edited at all: its first edit is what keeps
- // the text it had (File.zig), so with none there is nothing to lose.
- const saved = f.saved_hash orelse continue;
- if (std.hash.Wyhash.hash(0, f.content) == saved) continue;
+ // A file deleted on disk is asked about, edited or not: its text is
+ // nowhere else now (acme's winclean asks the same).
+ const gone = f.disk_gone and f.output == null;
+ if (!gone) {
+ if (f.revision == f.saved_revision or !(panes.Output.fileTraits(f.output).saves or scratch)) continue;
+ if (f.output != null and f.content.len < 100) continue;
+ // Dirty by a rename alone is no text to lose, as get says (ctl.zig).
+ // Nor is a buffer never edited at all: its first edit is what keeps
+ // the text it had (File.zig), so with none there is nothing to lose.
+ const saved = f.saved_hash orelse continue;
+ if (std.hash.Wyhash.hash(0, f.content) == saved) continue;
+ }
if (pane.discard_warned) |w| if (w.revision == f.revision and w.by == asking) continue;
pane.discard_warned = .{ .revision = f.revision, .by = asking };
// Scratches share a name: each is named with its pane's serial too,
@@ -803,10 +808,14 @@ pub const ThemeFile = struct {
pub const requires_arg = true;
pub const enabled = pardes.hosted;
pub fn run(c: Ctx) void {
- if (comptime enabled)
- colors.requestThemeFile(c.p, c.id, c.arg orelse return)
- else
- unreachable;
+ if (comptime !enabled) unreachable;
+ const arg = std.mem.trim(u8, c.arg orelse return, " \t\r\n");
+ // Said with why, not "invalid theme path".
+ if (!std.mem.endsWith(u8, arg, ".zon")) {
+ var said: [320]u8 = undefined;
+ return c.p.reportFailure(c.id, std.fmt.bufPrint(&said, "ThemeFile: {s}: invalid theme path: a theme file is a .zon (DumpThemes writes some to start from)", .{arg[0..@min(arg.len, 200)]}) catch "ThemeFile: invalid theme path: a theme file is a .zon");
+ }
+ colors.requestThemeFile(c.p, c.id, arg);
}
};
@@ -1375,8 +1384,8 @@ pub const Mini = struct {
/// A Find or Grep that finds nothing fails as one, in words 9ns reads as
/// ENOENT (`not found`), the same for both.
-const e_search_miss_find = "find: no match, not found";
-const e_search_miss_grep = "grep: no match, not found";
+const e_search_miss_find = "find: name not found";
+const e_search_miss_grep = "grep: pattern not found";
/// List the files below this pane's directory whose names hold its argument, in a +Search.
pub const Find = struct {
@@ -1818,6 +1827,7 @@ const Board = struct {
writeWord(addr, value);
const back = readWord(addr);
var buf: [96]u8 = undefined;
+ // unreachable below: three 8-digit hex words and 18 bytes fit 96
p.setMessage(id, std.fmt.bufPrint(
&buf,
"{x:0>8}: wrote {x:0>8}, reads {x:0>8}",
@@ -1840,6 +1850,7 @@ const Board = struct {
if (!toggle(p.host.ctx, pin, &was, &now)) return Error.BadPin;
var buf: [48]u8 = undefined;
+ // unreachable: three small numbers and 10 bytes fit 48
p.setMessage(id, std.fmt.bufPrint(&buf, "GPIO {d}: {d}->{d}", .{ pin, was, now }) catch unreachable);
}