Skip to content

Commit 0fd3c7b

Browse files
committed
add character offset for method_declaration renaming
1 parent 9ba7ded commit 0fd3c7b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lua/auto-fix-return/lib.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,15 @@ M.wrap_golang_return = function()
169169

170170
-- If the cursor is positioned outside of the immediate return declaration match then we do not want to touch it as this can
171171
-- cause weird behavior when editing parts of a function that are unrelated to the return declaration and if there is a weird edge that triggers
172-
if cursor_row < final_start_row + 1 or cursor_row > final_end_row + 1 or cursor_col < final_start_col or cursor_col > final_end_col then
172+
--
173+
-- We offset the final column start value to avoid edgecases with regards to using 'daw' or similar on a method_declaration
174+
-- E.G
175+
-- daw
176+
-- func (f Foo) B|ar() int {}
177+
-- ->
178+
-- func (f Foo) () int {}
179+
-- This parse will break without the final_start_col offset
180+
if cursor_row < final_start_row + 1 or cursor_row > final_end_row + 1 or cursor_col < final_start_col + 1 or cursor_col > final_end_col then
173181
return
174182
end
175183

0 commit comments

Comments
 (0)