From f02d304341654488e2553e50295e2658d260555b Mon Sep 17 00:00:00 2001 From: Zackary Schreur Date: Wed, 29 May 2024 09:26:16 -0400 Subject: [PATCH] Fix conflicts so that it works when there are less than 3 spaces --- lua/telescope-jj/conflicts.lua | 2 +- lua/telescope-jj/conflicts.test.lua | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 lua/telescope-jj/conflicts.test.lua diff --git a/lua/telescope-jj/conflicts.lua b/lua/telescope-jj/conflicts.lua index 9a3422d..0f033bc 100644 --- a/lua/telescope-jj/conflicts.lua +++ b/lua/telescope-jj/conflicts.lua @@ -17,7 +17,7 @@ return function(opts) local results = {} for _, str in ipairs(cmd_output) do -- https://github.com/martinvonz/jj/blob/9a5b001d58353afb7ea6cb894c22d80878b811ae/cli/src/cli_util.rs#L1778 - local word = string.match(str, "^(.-)%s%s%s") + local word = string.match(str, "^(.-)%s+%a+%-sided conflict$") table.insert(results, word) end diff --git a/lua/telescope-jj/conflicts.test.lua b/lua/telescope-jj/conflicts.test.lua new file mode 100644 index 0000000..632af72 --- /dev/null +++ b/lua/telescope-jj/conflicts.test.lua @@ -0,0 +1,12 @@ +local s1 = "file two-sided conflict" +local s2 = "file two-sided conflict" +local s3 = "file two-sided conflict" +local s4 = "file three-sided conflict" +local s5 = "file two-sided conflict two-sided conflict" + +local pattern = "^(.-)%s+%a+%-sided conflict$" +assert(string.match(s1, pattern) == "file") +assert(string.match(s2, pattern) == "file") +assert(string.match(s3, pattern) == "file") +assert(string.match(s4, pattern) == "file") +assert(string.match(s5, pattern) == "file two-sided conflict")