summaryrefslogtreecommitdiff
path: root/src/builtins.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/builtins.zig')
-rw-r--r--src/builtins.zig5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/builtins.zig b/src/builtins.zig
index 27a1d36d..4d257a9e 100644
--- a/src/builtins.zig
+++ b/src/builtins.zig
@@ -986,6 +986,11 @@ pub const ClipReplace = struct {
pub const Save = struct {
pub const takes_arg = true;
pub fn run(c: Ctx) void {
+ // A PDF or an image shows a file it does not hold as text: there
+ // is nothing of its own to write, bare or to a path. Said, never a
+ // silent success.
+ if (c.pane.file == null and !c.pane.isTerminal())
+ return c.p.reportFailure(c.id, if (c.pane.hasPdf()) "Save: a PDF pane has no text to save" else "Save: an image pane has no text to save");
const path = std.mem.trim(u8, c.arg orelse "", " \t\r\n");
if (path.len > 0) return exec.saveTo(c.p, c.id, path);
if (c.pane.file) |file| if (file.output == null) return exec.saveFile(c.p, c.id);