diff --git a/src/commands.cc b/src/commands.cc index 4a5eceaf..6143179d 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -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"); 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); write_buffer_to_file(buffer, filename); diff --git a/src/file.cc b/src/file.cc index 29e285e9..bf592689 100644 --- a/src/file.cc +++ b/src/file.cc @@ -280,8 +280,7 @@ void write_buffer_to_fd(Buffer& buffer, int fd) void write_buffer_to_file(Buffer& buffer, StringView filename) { - int fd = open(parse_filename(filename).c_str(), - O_CREAT | O_WRONLY | O_TRUNC, 0644); + int fd = open(filename.zstr(), O_CREAT | O_WRONLY | O_TRUNC, 0644); if (fd == -1) throw file_access_error(filename, strerror(errno)); diff --git a/src/main.cc b/src/main.cc index 24f1ae4b..845a8ab5 100644 --- a/src/main.cc +++ b/src/main.cc @@ -692,9 +692,9 @@ int run_filter(StringView keystr, StringView commands, ConstArrayViewname() + suffix_backup); apply_to_buffer(*buffer); - write_buffer_to_file(*buffer, file); + write_buffer_to_file(*buffer, buffer->name()); buffer_manager.delete_buffer(*buffer); } if (not isatty(0))