PR: Add multiline split & merge functionality to the Editor#25913
PR: Add multiline split & merge functionality to the Editor#25913hprodh wants to merge 3 commits intospyder-ide:masterfrom
Conversation
ccordoba12
left a comment
There was a problem hiding this comment.
Thanks for your work on this @hprodh!
And sorry for the big number of suggestions, they are only meant to make your code easier to read. The functionality looks good to me, although I haven't tested it yet.
If you haven't worked with suggestions before, please read this to learn how to apply them all in a single commit.
Coding style refinements accepted Co-authored-by: Carlos Cordoba <ccordoba12@gmail.com>
|
Thanks for your review @ccordoba12 . I tried to read the page but I think it is a bit outdated... anyway I went to the PR page, under the tab "Files changed", there I could click on "add to batch" (or whatever), I've done it for all suggestions. I did not see a button "commit batch" at the end, but now I see a second commit in the PR thread containing the accepted changes, thus I think it is done (is it ?)... And no problem for the number of suggestions, I admit my coding style is a bit 'dense' 😆 |
|
@ccordoba12 I did not translate the functions for every locale (and I won't), but I tested switching spyder to another language, the GUI entries still appear and work. |


Description of Changes
Added Multiline split and merge operations to editor.
(note : no unit tests written)
Added
replace_selected_textandauto_select_textmethods toCodeEditorincodeeditor.py, for conveniently auto selecting line or word under cursor and replacing selected text by preserving selection. ->transform_upper_caseand ``transform_upper_case` benefit now from selection preservation.Added
transform_multilinemethod, that usesast(imported now at top-level incodeeditor.py) to parse sequences (of list/tuple items or args/kwargs combinations) or assignments within single or multiple lines of code, to output the one-line (merge) or one-per-line (split) version.Added
multiline_splitandmultiline_mergefunctions, calling all of the introduced methods, and handling indentation, to transform selected code to multiline or one-line in the editor.Added 2 keyboard shortcut entries in
config/main.py, assigning Alt+Shift+M to 'multiline split' operation and Alt+M to 'multiline merge'.Video demo is here (but some trailing newline handling error has been fixed before PR).
Issue(s) Resolved
Fixes #25908
Affirmation
By submitting this Pull Request or typing my (user)name below,
I affirm the Developer Certificate of Origin
with respect to all commits and content included in this PR,
and understand I am releasing the same under Spyder's MIT (Expat) license.
I certify the above statement is true and correct:
hprodh