Ensure rename-buffer uses a filename for file buffers

Fixes #4391
This commit is contained in:
Maxime Coste 2021-10-24 09:30:31 +11:00
parent 5c1e10decb
commit 7c6f111d5f

View File

@ -864,7 +864,9 @@ const CommandDesc rename_buffer_cmd = {
if (parser.get_switch("file")) if (parser.get_switch("file"))
buffer.flags() |= Buffer::Flags::File; buffer.flags() |= Buffer::Flags::File;
if (not buffer.set_name(parser[0])) const bool is_file = (buffer.flags() & Buffer::Flags::File);
if (not buffer.set_name(is_file ? parse_filename(parser[0]) : parser[0]))
throw runtime_error(format("unable to change buffer name to '{}': a buffer with this name already exists", parser[0])); throw runtime_error(format("unable to change buffer name to '{}': a buffer with this name already exists", parser[0]));
} }
}; };