Assume filename passed to write_buffer_to_file is already parsed
This commit is contained in:
parent
5103b15b84
commit
30e6387071
|
@ -323,7 +323,7 @@ void write_buffer(const ParametersParser& parser, Context& context, const ShellC
|
||||||
throw runtime_error("cannot overwrite the buffer when in readonly mode");
|
throw runtime_error("cannot overwrite the buffer when in readonly mode");
|
||||||
|
|
||||||
auto filename = parser.positional_count() == 0 ?
|
auto filename = parser.positional_count() == 0 ?
|
||||||
buffer.name() : parse_filename(parser[0]);
|
buffer.name() : parse_filename(parser[0]);
|
||||||
|
|
||||||
context.hooks().run_hook("BufWritePre", filename, context);
|
context.hooks().run_hook("BufWritePre", filename, context);
|
||||||
write_buffer_to_file(buffer, filename);
|
write_buffer_to_file(buffer, filename);
|
||||||
|
|
|
@ -280,8 +280,7 @@ void write_buffer_to_fd(Buffer& buffer, int fd)
|
||||||
|
|
||||||
void write_buffer_to_file(Buffer& buffer, StringView filename)
|
void write_buffer_to_file(Buffer& buffer, StringView filename)
|
||||||
{
|
{
|
||||||
int fd = open(parse_filename(filename).c_str(),
|
int fd = open(filename.zstr(), O_CREAT | O_WRONLY | O_TRUNC, 0644);
|
||||||
O_CREAT | O_WRONLY | O_TRUNC, 0644);
|
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
throw file_access_error(filename, strerror(errno));
|
throw file_access_error(filename, strerror(errno));
|
||||||
|
|
||||||
|
|
|
@ -692,9 +692,9 @@ int run_filter(StringView keystr, StringView commands, ConstArrayView<StringView
|
||||||
{
|
{
|
||||||
Buffer* buffer = open_file_buffer(file);
|
Buffer* buffer = open_file_buffer(file);
|
||||||
if (not suffix_backup.empty())
|
if (not suffix_backup.empty())
|
||||||
write_buffer_to_file(*buffer, file + suffix_backup);
|
write_buffer_to_file(*buffer, buffer->name() + suffix_backup);
|
||||||
apply_to_buffer(*buffer);
|
apply_to_buffer(*buffer);
|
||||||
write_buffer_to_file(*buffer, file);
|
write_buffer_to_file(*buffer, buffer->name());
|
||||||
buffer_manager.delete_buffer(*buffer);
|
buffer_manager.delete_buffer(*buffer);
|
||||||
}
|
}
|
||||||
if (not isatty(0))
|
if (not isatty(0))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user