From 4eb3e932e5006c925069c2386c0c6da6bb5baccb Mon Sep 17 00:00:00 2001 From: Darkhan Date: Sat, 26 Aug 2023 15:47:18 +0100 Subject: [PATCH] Make commit pattern more accurate (#973) Sometimes when hovering over updated plugins and triggering `diff` with `d` key, I get an empty `diff` view. I traced the problem to a very generic `commit_pattern` which currently matches any alphanumeric sequence of 7 characters surrounded by "word boundary" / frontier patterns. I adjusted the regex to match only `[a-z0-9] * 7` which should make this issue appear less. I am keeping the older frontier sets `%f[%w]` and `%f[%W]` because if I switch to `%f[a-f0-9]` and `%f[^0-9a-f]` I will be matching strings like `zzz1234567xxx`. --- lua/lazy/view/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazy/view/init.lua b/lua/lazy/view/init.lua index 93611e2..d179f11 100644 --- a/lua/lazy/view/init.lua +++ b/lua/lazy/view/init.lua @@ -159,7 +159,7 @@ function M:open_url(path) end function M:setup_patterns() - local commit_pattern = "%f[%w](" .. string.rep("%w", 7) .. ")%f[%W]" + local commit_pattern = "%f[%w](" .. string.rep("[a-f0-9]", 7) .. ")%f[%W]" self:on_pattern(ViewConfig.keys.hover, { [commit_pattern] = function(hash) self:diff({ commit = hash, browser = true })