@@ -13,11 +13,13 @@ local strFuncs = require("spider.extras.utf8-support").stringFuncs
1313local function getMatchpos (line , pattern , endOfWord , searchOffset )
1414 -- special case: pattern with unescaped ^/$, since there can only be one
1515 -- match and since gmatch won't work with them
16- local endsWithUnescapedDollar = pattern :find (" f[%$]$$" ) -- not `:find("$$")`, could be escaped $, see #63
17- if pattern :find (" ^^" ) or endsWithUnescapedDollar then
16+
17+ -- trailing $ could be escaped $, see #63
18+ local endsWithUnescapedDollar = vim .endswith (pattern , " $" ) and not vim .endswith (pattern , " %$" )
19+ if vim .startswith (pattern , " ^" ) or endsWithUnescapedDollar then
1820 -- checking for high col count for virtualedit
1921 if endsWithUnescapedDollar and searchOffset > strFuncs .len (line ) then return false end
20- if pattern : find ( " ^ ^" ) and searchOffset ~= 0 then return false end
22+ if vim . startswith ( pattern , " ^" ) and searchOffset ~= 0 then return false end
2123
2224 local startPos , endPos = strFuncs .find (line , pattern )
2325 if not startPos or not endPos then return false end
@@ -27,6 +29,8 @@ local function getMatchpos(line, pattern, endOfWord, searchOffset)
2729 return false
2830 end
2931
32+ ---- -------------------------------------------------------------------------
33+
3034 -- `()` makes gmatch return the position of that group
3135 pattern = endOfWord and (pattern .. " ()" ) or (" ()" .. pattern )
3236
0 commit comments