write command refuse to write a scratch file when no filename is given

This commit is contained in:
Maxime Coste 2012-08-07 23:20:53 +02:00
parent 207f2f6bb9
commit 8e0f99a03b

View File

@ -271,6 +271,10 @@ void write_buffer(const CommandParameters& params, Context& context)
throw wrong_argument_count(); throw wrong_argument_count();
Buffer& buffer = context.window().buffer(); 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() String filename = params.empty() ? buffer.name()
: parse_filename(params[0]); : parse_filename(params[0]);