Improves import comment handling so comments travel with imports, fixes comment parsing edge cases, and fixes two ast-grep display and preview inconsistencies.
Import handling
Organizing imports keeps same-line and directly-above comments with their statements; only comments separated from the next import by a blank line still split sorting.
Imports containing comments are kept verbatim instead of being regenerated, which previously dropped the comment.
Python groups follow isort's default order: import x lines by module, then from x import ... lines by module.
Removing an import now deletes its end-of-line comment along with it.
Line comments end at \r or \n instead of only \n, so removal and organize stop at the line break in CR-only files instead of erasing following code.
Lua long comments with level markers (--[=[, --[==[, ...) are recognized; code after a leveled comment on an import line is no longer deleted.
ast-grep
Dry-run rewrites that fail syntax validation now refuse with the affected file names, matching what apply does.
ast_search returns meta_variable_text; variadic $$$ captures render as their source text (e.g. $A: 1, 2) instead of the joined node list (. $A: 1,,,2).
Confidence Score: 5/5
The changes appear safe to merge; no blocking issue remains.
Summary
The PR keeps comments with imports, improves Python import sorting, rejects invalid rewrite previews, and displays variadic captures as source text.
Organizing imports keeps comments with the statements they describe.
Removing an import also removes its same-line comment.
Ast-grep dry runs refuse rewrites that fail syntax checks.
Ast-grep search shows variadic captures as they appear in source.