Skip to content

Commit 7e55234

Browse files
CopilotKilynho
andcommitted
Address code review feedback: remove unused variable and improve efficiency
- Remove unused else_indent variable in fix_else_after_close_brace - Improve fix_consecutive_strings to prevent infinite loop edge cases - All 39 tests still passing Co-authored-by: Kilynho <[email protected]>
1 parent 3c50954 commit 7e55234

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

core.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -948,8 +948,6 @@ def callback(lines, idx):
948948
if line.startswith('else') and idx > 0:
949949
prev_line = lines[idx - 1].rstrip()
950950
if prev_line.endswith('}'):
951-
# Get indentation of else line
952-
else_indent = len(lines[idx]) - len(lines[idx].lstrip())
953951
# Merge: previous line + ' ' + current line
954952
lines[idx - 1] = prev_line + ' ' + line + '\n'
955953
# Remove current line
@@ -1001,8 +999,11 @@ def callback(lines, idx):
1001999
# Match two or more adjacent string literals
10021000
pattern = r'"([^"]*?)"\s+"([^"]*?)"'
10031001
if re.search(pattern, line):
1004-
# Merge consecutive strings
1005-
while re.search(pattern, line):
1002+
# Merge consecutive strings - keep replacing until no more matches
1003+
# This handles multiple consecutive strings like "a" "b" "c"
1004+
prev_line = None
1005+
while prev_line != line and re.search(pattern, line):
1006+
prev_line = line
10061007
line = re.sub(pattern, r'"\1\2"', line)
10071008
lines[idx] = line
10081009
return True

0 commit comments

Comments
 (0)