25
25
local function get_ref_under_cursor ()
26
26
local cite_format = config :get_cite_format ()
27
27
local start_str = cite_format .start_str
28
- local start_str_alt = cite_format .start_str_alt or {}
28
+ local start_pattern = cite_format .start_pattern
29
29
local ref_prefix = cite_format .ref_prefix
30
30
31
31
-- get current line and cursor position
@@ -41,17 +41,18 @@ local function get_ref_under_cursor()
41
41
-- Extract the word
42
42
local ref = current_line :sub (word_start_col , word_end_col )
43
43
44
- -- Create a combined list of start strings to check, with start_str first
45
- local all_start_strings = { start_str }
46
- vim .list_extend (all_start_strings , start_str_alt )
47
-
48
- -- Check all start strings and strip if found
49
- for _ , str in ipairs (all_start_strings ) do
50
- local escaped_str = str :gsub (" %W" , " %%%0" )
51
- local _ , ref_start = string.find (ref , escaped_str )
44
+ -- First check if a start pattern is defined and try to use it
45
+ if start_pattern then
46
+ local _ , pattern_end = ref :find (start_pattern )
47
+ if pattern_end then
48
+ ref = ref :sub (pattern_end + 1 )
49
+ end
50
+ elseif start_str then
51
+ -- If no pattern, use start_str
52
+ local escaped_start_str = start_str :gsub (" %W" , " %%%0" )
53
+ local _ , ref_start = string.find (ref , escaped_start_str )
52
54
if ref_start then
53
55
ref = string.sub (ref , ref_start + 1 )
54
- break -- Exit the loop once we've found a match
55
56
end
56
57
end
57
58
0 commit comments