-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] PR: Add multi-cursor editing to codeeditor #22996
base: master
Are you sure you want to change the base?
Conversation
Required manually tracking overwriteMode and leaving it disabled except for during keyEvent. This might be a fragile solution...
…to new line, and clears extra_cursors on goto_definition
…r. many TODO comments
…bool, and added #TODO notes
…r_all_cursors wrapper
…line length. Also revert to builtin cursor rendering for text dragging with single cursor.
Hello @athompson673! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2024-11-22 03:08:03 UTC |
handle_multi_cursor_keypress no longer an event reciever, instead directly called from keyPressEvent. This way we can cleanly emit sig_key_pressed for each cursor and respond to event.isAccepted. This implements ignoring keystrokes on folded lines.
… text similar to edits for delete function, emit a signal for each cursor prior to changing text as this prevents an out of order edit problem with code folding.
The delayed update model with the LSP makes it difficult to encapsulate the changes with a simple call to for_each_cursor. Future implementation might edit lsp_mixin?
…ecorator to two shortcuts
I am running into difficulty figuring out how to handle folded code blocks with the move/duplicate line up/down functions. It seems difficult to prevent edge cases from breaking the code folding state. Does anyone have experience with that system? |
Description of Changes
Multi-line editing has been a feature I've missed having in spyder for a long time. I frequently have a notepad++ scratchpad alongside spyder simply to copy blocks of text back and forth so that I can use the column cursor. I haven't been able to contribute money to the spyder project despite using it for about a decade now, but I can hopefully at least contribute some time.
I am an engineer, not a programmer so please criticize my work so we can make it better :)
I decided to implement the functionality directly inside the
codeeditor.CodeEditor
class as making it an editor extension would still require a great many edits to CodeEditor anyway. The basic implementation is to hide the original cursor when there are multiples, and manually draw the primary cursor and all extras on a timer. For many editor functions afor_each_cursor
wrapper does a lot of heavy lifting. Other functions need to be slightly tweaked directly. I think it is not particularly productive to try to implement code completion (snippets, call-tips, etc) during multi-cursor sessions, so I attempt to disable those functions appropriately.These are some deep changes to one of the most complicated parts of Spyder, so I will naturally need some help getting this code to a state where it's ready to be integrated. I know it is not yet fully ready, but I wanted to get the PR in so that more people could see it and maybe get interested in testing it.
Media1.mp4
TODO list:
Issue(s) Resolved
Fixes #2112
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: athompson673