-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[python console][feature] smart brackets #51391
[python console][feature] smart brackets #51391
Conversation
Nice work @YoannQDQ -- this autocompletion has been needing some love! Can you please restore the option to enable/disable this behaviour though? It's not universally liked and it's important to allow some way to disable it (eg I personally always disable bracket autocompletion in editors!) |
Sure, I'll add it back. Enclosing selected text with quotes/parenthesis/brackets should still be always on, right? Any thought on what should be the default value for the |
Thanks for that. +1 for disabling |
This sounds good to me. I think defaulting to bracket autocompletion is fine, so long as there's a way to disable this. That matches common IDE practice then (at least this is how Pycharm/other Jetbrains products/QtCreator default) |
Ok, I believe it is now ready to be merged! |
Co-authored-by: Nyall Dawson <nyall.dawson@gmail.com>
@YoannQDQ A documentation ticket will be opened at https://github.com/qgis/QGIS-Documentation when this PR is merged. Please update the description (not the comments) with helpful description and screenshot to help the work from documentors. Thank you! |
@YoannQDQ |
Motivation
The QGIS Python Console has an
autoCloseBracket
setting, which automatically insert a closing parentheses / brace / bracket when an opening char is entered.Proposal
Tweak
autoCloseBracket
behavior to mimic the behavior of modern IDEsAdd an
autoSurround
setting to surround selected text when typing quotes/parentheses/brackets.This is implemented in the
QgsCodeEditorPython
, so it also works in Expression Editor, Project Macro Editor, Script Editor, etc.When some text was selected (and
autoSurround
is on)"
then(
When no text is selected (and
autoCloseBracket
is on)Pairs of characters:
[
and]
{
and}
[
and]
"
and"
'
and'
Additionaly, for the characters
`
(backtick) and*
, only the enclose selected text feature is enabled