From dba037598843973b8c54bc5ce0318db4a0da439d Mon Sep 17 00:00:00 2001 From: Steven Arcangeli Date: Tue, 10 Dec 2024 15:22:19 -0800 Subject: [PATCH] fix: handle files with newlines in the name (#534) --- lua/oil/mutator/confirmation.lua | 2 ++ lua/oil/view.lua | 2 ++ 2 files changed, 4 insertions(+) diff --git a/lua/oil/mutator/confirmation.lua b/lua/oil/mutator/confirmation.lua index 4e86abc3..8bc80203 100644 --- a/lua/oil/mutator/confirmation.lua +++ b/lua/oil/mutator/confirmation.lua @@ -82,6 +82,8 @@ M.show = vim.schedule_wrap(function(actions, should_confirm, cb) else line = adapter.render_action(action) end + -- We can't handle lines with newlines in them + line = line:gsub("\n", "") table.insert(lines, line) local line_width = vim.api.nvim_strwidth(line) if line_width > max_line_width then diff --git a/lua/oil/view.lua b/lua/oil/view.lua index 15e50228..c6d96030 100644 --- a/lua/oil/view.lua +++ b/lua/oil/view.lua @@ -734,6 +734,8 @@ M.format_entry_cols = function(entry, column_defs, col_width, adapter, is_hidden if meta and meta.display_name then name = meta.display_name end + -- We can't handle newlines in filenames (and shame on you for doing that) + name = name:gsub("\n", "") -- First put the unique ID local cols = {} local id_key = cache.format_id(entry[FIELD_ID])