File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -120,8 +120,12 @@ def normalize_lines(selection):
120120
121121 # Insert a newline between each top-level statement, and append a newline to the selection.
122122 source = "\n " .join (statements ) + "\n "
123+ # If selection ends with trailing dictionary or list, remove last new-line for "cleaner run".
123124 if selection [- 2 ] == "}" or selection [- 2 ] == "]" :
124125 source = source [:- 1 ]
126+ # If the selection contains trailing return dictionary, insert newline to run automatically.
127+ if check_end_with_return_dict (selection ):
128+ source = source + "\n "
125129 except Exception :
126130 # If there's a problem when parsing statements,
127131 # append a blank line to end the block and send it as-is.
@@ -134,6 +138,11 @@ def normalize_lines(selection):
134138min_key = None
135139
136140
141+ def check_end_with_return_dict (code ):
142+ stripped_code = code .strip ()
143+ return stripped_code .endswith ("}" ) and "return {" in stripped_code .strip ()
144+
145+
137146def check_exact_exist (top_level_nodes , start_line , end_line ):
138147 return [
139148 node
You can’t perform that action at this time.
0 commit comments