From 8e0f99a03b0704b95c98b92deeb8041eb9703933 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 7 Aug 2012 23:20:53 +0200 Subject: [PATCH] write command refuse to write a scratch file when no filename is given --- src/commands.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/commands.cc b/src/commands.cc index 44e754ed..5b0f4b4c 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -271,6 +271,10 @@ void write_buffer(const CommandParameters& params, Context& context) throw wrong_argument_count(); Buffer& buffer = context.window().buffer(); + + if (params.empty() and buffer.type() == Buffer::Type::Scratch) + throw runtime_error("cannot write scratch buffer without a filename"); + String filename = params.empty() ? buffer.name() : parse_filename(params[0]);