From ba1f50a9a81f65c07af584065ab9a5ad2a9e5fe0 Mon Sep 17 00:00:00 2001 From: Steven Arcangeli Date: Sun, 30 Mar 2025 15:14:11 -0700 Subject: [PATCH] fix: file time column escapes ()[] chars in parser (#603) --- lua/oil/adapters/files.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lua/oil/adapters/files.lua b/lua/oil/adapters/files.lua index 8fb1835..28e647b 100644 --- a/lua/oil/adapters/files.lua +++ b/lua/oil/adapters/files.lua @@ -183,7 +183,17 @@ for _, time_key in ipairs({ "ctime", "mtime", "atime", "birthtime" }) do -- Replace placeholders with a pattern that matches non-space characters (e.g. %H -> %S+) -- and whitespace with a pattern that matches any amount of whitespace -- e.g. "%b %d %Y" -> "%S+%s+%S+%s+%S+" - pattern = fmt:gsub("%%.", "%%S+"):gsub("%s+", "%%s+") + pattern = fmt + :gsub("%%.", "%%S+") + :gsub("%s+", "%%s+") + -- escape `()[]` because those are special characters in Lua patterns + :gsub( + "%(", + "%%(" + ) + :gsub("%)", "%%)") + :gsub("%[", "%%[") + :gsub("%]", "%%]") else pattern = "%S+%s+%d+%s+%d%d:?%d%d" end