Skip to content

Commit 3c3bede

Browse files
authored
fix: 🐛 fixed super fixing (#425)
* fix: 🐛 fixed super fixing with the changes from #420 we have to start the search for the colsing_paren_index at `func_def_end - 1` * refactor: ♻️ added comment and -1 in `get_function_parameters()`
1 parent 4cc07b2 commit 3c3bede

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

addons/mod_loader/internal/mod_hook_preprocessor.gd

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ static func get_function_parameters(method_name: String, text: String, is_static
152152
if not is_top_level_func(text, result.get_start(), is_static):
153153
return get_function_parameters(method_name, text, is_static, result.get_end())
154154

155-
var closing_paren_index := get_closing_paren_index(opening_paren_index, text)
155+
# Shift the func_def_end index back by one to start on the opening parentheses.
156+
# Because the match_func_with_whitespace().get_end() is the index after the opening parentheses.
157+
var closing_paren_index := get_closing_paren_index(opening_paren_index - 1, text)
156158
if closing_paren_index == -1:
157159
return ""
158160

@@ -224,7 +226,9 @@ static func edit_vanilla_method(
224226

225227

226228
static func fix_method_super(method_name: String, func_def_end: int, text: String, regex_func_body: RegEx, regex_super_call: RegEx, offset := 0) -> String:
227-
var closing_paren_index := get_closing_paren_index(func_def_end, text)
229+
# Shift the func_def_end index back by one to start on the opening parentheses.
230+
# Because the match_func_with_whitespace().get_end() is the index after the opening parentheses.
231+
var closing_paren_index := get_closing_paren_index(func_def_end - 1, text)
228232
if closing_paren_index == -1:
229233
return text
230234
var func_body_start_index := text.find(":", closing_paren_index) +1

0 commit comments

Comments
 (0)