Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Nyall Dawson <nyall.dawson@gmail.com>
  • Loading branch information
YoannQDQ and nyalldawson committed Jan 10, 2023
1 parent 451317b commit f1843ef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/gui/codeeditors/qgscodeeditorpython.cpp
Expand Up @@ -285,9 +285,9 @@ void QgsCodeEditorPython::keyPressEvent( QKeyEvent *event )
// Automatically insert "import" after "from xxx " if option is enabled
if ( autoInsertImport && eText == " " )
{
const QString txt = text( line );
const QRegularExpression re( QStringLiteral( "^from [\\w.]+$" ) );
if ( re.match( txt.trimmed() ).hasMatch() )
const QString lineText = text( line );
const thread_local QRegularExpression re( QStringLiteral( "^from [\\w.]+$" ) );
if ( re.match( lineText.trimmed() ).hasMatch() )
{
insert( QStringLiteral( " import" ) );
setCursorPosition( line, column + 7 );
Expand Down Expand Up @@ -443,7 +443,7 @@ QString QgsCodeEditorPython::characterBeforeCursor() const
int position = positionFromLineIndex( line, index );
if ( position <= 0 )
{
return "";
return QString();
}
return text( position - 1, position );
}
Expand All @@ -455,7 +455,7 @@ QString QgsCodeEditorPython::characterAfterCursor() const
int position = positionFromLineIndex( line, index );
if ( position >= length() )
{
return "";
return QString();
}
return text( position, position + 1 );
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/codeeditors/qgscodeeditorpython.h
Expand Up @@ -80,7 +80,7 @@ class GUI_EXPORT QgsCodeEditorPython : public QgsCodeEditor
*
* \since QGIS 3.30
*/
bool isCursorInsideString() const;
bool isCursorInsideStringLiteralOrComment() const;

/**
* Returns the character before the cursor, or an empty string if cursor is set at start
Expand Down

0 comments on commit f1843ef

Please sign in to comment.