Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for complete pattern matches later in the target text #1900

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lua/cmp/matcher.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@ matcher.match = function(input, word, option)
local no_symbol_match = false
while input_end_index <= #input and word_index <= #word do
local m = matcher.find_match_region(input, input_start_index, input_end_index, word, word_index)
if input_start_index ~= 1 then
-- If we can find a bigger match later, add it to the list. Prefer
-- a larger, later match over a match spread over more small pieces.
local m2 = matcher.find_match_region(input, 1, 1, word, word_index)
if m and m2 then
if m2.input_match_end >= m.input_match_end then
m = m2
end
elseif m2 and not m then
m = m2
end
end
if m and input_end_index <= m.input_match_end then
m.index = word_bound_index
input_start_index = m.input_match_start + 1
Expand Down
Loading