Skip to content

Commit

Permalink
tweak auto close brackets
Browse files Browse the repository at this point in the history
  • Loading branch information
YoannQDQ authored and nyalldawson committed Mar 31, 2023
1 parent d5cb7c9 commit 0a26096
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/gui/codeeditors/qgscodeeditorpython.cpp
Expand Up @@ -337,8 +337,12 @@ void QgsCodeEditorPython::keyPressEvent( QKeyEvent *event )
}

// Else, if not inside a string or comment and an opening character
// is entered, also insert the closing character
else if ( !isCursorInsideStringLiteralOrComment() && sCompletionPairs.contains( eText ) )
// is entered, also insert the closing character, provided the next
// character is a space, a colon, or a closing character
else if ( !isCursorInsideStringLiteralOrComment()
&& sCompletionPairs.contains( eText )
&& ( nextChar.isEmpty() || nextChar.at( 0 ).isSpace() || nextChar == ":" || sCompletionPairs.key( nextChar ) != "" )
)
{
// Check if user is not entering triple quotes
if ( !( ( eText == "\"" || eText == "'" ) && prevChar == eText ) )
Expand Down

0 comments on commit 0a26096

Please sign in to comment.