From 81d3eadd09a606963493e41dc96ea7b6f470368c Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 8 Jul 2014 19:24:51 +0100 Subject: [PATCH] :edit! without argument reload current buffer --- src/commands.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/commands.cc b/src/commands.cc index 40f58145..6bf62164 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -97,7 +97,11 @@ struct CommandDesc template void edit(const ParametersParser& parser, Context& context) { - const String name = parser[0]; + if (parser.positional_count() == 0 and not force_reload) + throw wrong_argument_count(); + + auto& name = parser.positional_count() > 0 ? parser[0] + : context.buffer().name(); Buffer* buffer = nullptr; if (not force_reload) @@ -141,7 +145,7 @@ ParameterDesc edit_params{ SwitchMap{ { "scratch", { false, "create a scratch buffer, not linked to a file" } }, { "fifo", { true, "create a buffer reading its content from a named fifo" } }, { "scroll", { false, "place the initial cursor so that the fifo will scroll to show new data" } } }, - ParameterDesc::Flags::None, 1, 3 + ParameterDesc::Flags::None, 0, 3 }; const CommandDesc edit_cmd = {