File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3838
3939local function external_command_args (cur_lines )
4040 local args = {}
41- for arg in string.gmatch (self .config .autoclip_custom_args , " %S+" ) do
42- if arg == ' %MPV_PRIMARY%' then
43- arg = cur_lines .primary
44- elseif arg == ' %MPV_SECONDARY%' then
45- arg = cur_lines .secondary
41+
42+ -- Append a trailing space to ensure the last argument is captured by the %s+ pattern.
43+ local config_str = self .config .autoclip_custom_args .. " "
44+
45+ -- PATTERN EXPLANATION: [=[(["']?)(.-)%1%s+]=]
46+ -- 1. (["']?) : Capture group 1. Matches an optional single or double quote.
47+ -- 2. (.-) : Capture group 2. Non-greedy match of any character (the actual content).
48+ -- 3. %1 : Back-reference. Ensures the closing quote matches the opening quote.
49+ -- 4. %s+ : Matches one or more trailing whitespace characters to delimit arguments.
50+ local pattern = [=[ (["']?)(.-)%1%s+]=]
51+
52+ for _ , arg in config_str :gmatch (pattern ) do
53+ if arg ~= " " then
54+ if arg == ' %MPV_PRIMARY%' then
55+ arg = cur_lines .primary
56+ elseif arg == ' %MPV_SECONDARY%' then
57+ arg = cur_lines .secondary
58+ end
59+
60+ table.insert (args , arg )
4661 end
47- table.insert (args , arg )
4862 end
63+
4964 return args
5065end
5166
You can’t perform that action at this time.
0 commit comments