summaryrefslogtreecommitdiff
path: root/src/builtins.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/builtins.zig')
-rw-r--r--src/builtins.zig23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/builtins.zig b/src/builtins.zig
index 8788e65f..8a01b3d6 100644
--- a/src/builtins.zig
+++ b/src/builtins.zig
@@ -562,7 +562,9 @@ fn warnModifiedIn(c: Ctx, asking: Pane.Discarding, which: Asked) bool {
}
if (count > 0) {
listed.print(arena, "\n{s} again to discard\n", .{@tagName(asking)}) catch {};
- if (c.p.gpa.dupe(u8, listed.items)) |content| panes.Output.openUnsaved(c.p, c.id, content) else |_| {}
+ // A refused Delcol changes nothing, the layout included: its records
+ // and its notice say it, and no +Unsaved opens.
+ if (asking != .Delcol) if (c.p.gpa.dupe(u8, listed.items)) |content| panes.Output.openUnsaved(c.p, c.id, content) else |_| {};
var short: [96]u8 = undefined;
c.p.reportFailure(c.id, std.fmt.bufPrint(&short, "{d} unsaved pane{s} \u{2014} {s} again to discard", .{ count, if (count == 1) "" else "s", @tagName(asking) }) catch "unsaved panes");
}
@@ -572,7 +574,8 @@ fn warnModifiedIn(c: Ctx, asking: Pane.Discarding, which: Asked) bool {
std.fmt.bufPrint(&said_buf, "{s}: Modified ({s} again to discard)", .{ one, @tagName(asking) })
else
std.fmt.bufPrint(&said_buf, "{d} unsaved panes: Modified ({s} again to discard)", .{ count, @tagName(asking) })) catch "unsaved panes: Modified";
- const kept = @import("Messages.zig").clip(said, c.p.fs.failure.len);
+ var room: @TypeOf(c.p.fs.failure) = undefined;
+ const kept = pardes.ctlfs.fitErr(said, &room);
@memcpy(c.p.fs.failure[0..kept.len], kept);
c.p.fs.failure_len = @intCast(kept.len);
}
@@ -1372,11 +1375,12 @@ pub const Pet = struct {
/// Open a minimap of the file in braille dots.
pub const Mini = struct {
pub const takes_arg = true;
+ pub const requires_arg = true; // a file to map: bare, wrong #args (EINVAL)
pub const output: OutputTraits = .{ .name = "Mini", .doc = true };
pub fn run(c: Ctx) void {
panes.Mini.open(c.p, c.id, c.arg orelse "") catch |err|
- c.p.reportError(c.id, "mini", err);
+ c.p.reportError(c.id, "Mini", err);
}
};
@@ -1384,8 +1388,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: name not found";
-const e_search_miss_grep = "grep: pattern 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 {
@@ -1395,7 +1399,7 @@ pub const Find = struct {
pub fn run(c: Ctx) void {
const pat = std.mem.trim(u8, c.arg orelse "", " \t\r\n");
if (pat.len > 0) {
- const rows = look.runSearch(c.p, c.id, pat, .find, .top, false) catch |err| return c.p.reportError(c.id, "find", err);
+ const rows = look.runSearch(c.p, c.id, pat, .find, .top, false) catch |err| return c.p.reportError(c.id, "Find", err);
if (rows == 0) c.p.reportFailure(c.id, e_search_miss_find);
return;
}
@@ -1412,7 +1416,7 @@ pub const Grep = struct {
pub fn run(c: Ctx) void {
const pat = std.mem.trim(u8, c.arg orelse "", " \t\r\n");
if (pat.len > 0) {
- const rows = look.runSearch(c.p, c.id, pat, .grep, .top, false) catch |err| return c.p.reportError(c.id, "grep", err);
+ const rows = look.runSearch(c.p, c.id, pat, .grep, .top, false) catch |err| return c.p.reportError(c.id, "Grep", err);
if (rows == 0) c.p.reportFailure(c.id, e_search_miss_grep);
return;
}
@@ -2002,7 +2006,7 @@ test "Exit and Restore name a modified +New scratch as well as files" {
// Delcol, Restore and Exit name it the same way.
p.fs.failure_len = 0;
try std.testing.expect(p.executeBuiltinLine(p.active, "Delcol"));
- try std.testing.expect(std.mem.indexOf(u8, unsavedList(p), "Delcol again to discard") != null);
+ try std.testing.expect(std.mem.indexOf(u8, unsavedList(p), "Delcol again to discard") == null);
try std.testing.expect(std.mem.indexOf(u8, unsavedList(p), named[0 .. config.scratch_buffer.len + 7]) != null);
}
@@ -2015,7 +2019,8 @@ test "Del and Delcol refuse a pane with unsaved text once, as acme's do, and clo
const serial = pane.serial;
try std.testing.expect(p.executeBuiltinLine(p.active, "Delcol"));
try std.testing.expect(p.paneBySerial(serial) != null);
- try std.testing.expect(std.mem.endsWith(u8, unsavedList(p), ": Modified\n\nDelcol again to discard\n"));
+ // A refused Delcol changes nothing: no +Unsaved (its records say it).
+ try std.testing.expect(std.mem.indexOf(u8, unsavedList(p), "Delcol") == null);
// Each word is warned on its own: Del asks too, then closes.
try std.testing.expect(p.executeBuiltinLine(p.active, "Del"));
try std.testing.expect(p.paneBySerial(serial) != null);