File tree 3 files changed +9
-9
lines changed
3 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -80,7 +80,8 @@ function text_edits.guess_text_edit(item)
80
80
-- convert to 0-index
81
81
return {
82
82
range = {
83
- start = { line = current_line - 1 , character = range [1 ] },
83
+ start = { line = current_line - 1 , character = range [1 ] - 1 },
84
+ -- don't - 1 on the end col since it's exclusive while get_regex_around_cursor assumes inclusive
84
85
[' end' ] = { line = current_line - 1 , character = range [2 ] },
85
86
},
86
87
newText = word ,
Original file line number Diff line number Diff line change @@ -67,10 +67,9 @@ function fuzzy.get_query()
67
67
)
68
68
-- Since sub(1, 1) returns a single char string, we need to check if that single char matches
69
69
-- and otherwise return an empty string
70
- if range [1 ] == range [2 ] and line :sub (range [1 ] + 1 , range [1 ] + 1 ):match (cmp_config .keyword_regex ) == nil then
71
- return ' '
72
- end
73
- return string.sub (line , range [1 ] + 1 , range [2 ] + 1 )
70
+ if range [1 ] == range [2 ] and line :sub (range [1 ], range [1 ]):match (cmp_config .keyword_regex ) == nil then return ' ' end
71
+ vim .print (string.sub (line , range [1 ], range [2 ]))
72
+ return string.sub (line , range [1 ], range [2 ])
74
73
end
75
74
76
75
return fuzzy
Original file line number Diff line number Diff line change @@ -152,23 +152,23 @@ end
152
152
--- @return number[]
153
153
--- TODO: switch to return start_col, length to simplify downstream logic
154
154
function utils .get_regex_around_cursor (range , regex , exclude_from_prefix_regex )
155
- local current_col = vim .api .nvim_win_get_cursor (0 )[2 ]
155
+ local current_col = vim .api .nvim_win_get_cursor (0 )[2 ] + 1
156
156
local line = vim .api .nvim_get_current_line ()
157
157
158
158
-- Search backward for the start of the word
159
159
local start_col = current_col
160
160
while start_col > 0 do
161
- local char = line :sub (start_col , start_col )
161
+ local char = line :sub (start_col - 1 , start_col - 1 )
162
162
if char :match (regex ) == nil then break end
163
163
start_col = start_col - 1
164
164
end
165
165
166
- local end_col = current_col
166
+ local end_col = current_col - 1
167
167
168
168
-- Search forward for the end of the word if configured
169
169
if range == ' full' then
170
170
while end_col < # line do
171
- local char = line :sub (end_col + 1 , end_col + 1 )
171
+ local char = line :sub (end_col , end_col )
172
172
if char :match (regex ) == nil then break end
173
173
end_col = end_col + 1
174
174
end
You can’t perform that action at this time.
0 commit comments