Skip to content

Commit

Permalink
Fix backspace does not work on empty line
Browse files Browse the repository at this point in the history
  • Loading branch information
YoannQDQ authored and nyalldawson committed Jan 10, 2023
1 parent 6562062 commit 04290ea
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/gui/codeeditors/qgscodeeditorpython.cpp
Expand Up @@ -208,7 +208,6 @@ void QgsCodeEditorPython::keyPressEvent( QKeyEvent *event )
{
return QgsCodeEditor::keyPressEvent( event );
}

const bool ctrlModifier = event->modifiers() & Qt::ControlModifier;

// Toggle comment when user presses Ctrl+:
Expand Down Expand Up @@ -244,7 +243,7 @@ void QgsCodeEditorPython::keyPressEvent( QKeyEvent *event )
// When backspace is pressed inside an opening/closing pair, remove both characters
if ( event->key() == Qt::Key_Backspace )
{
if ( PAIRS[prevChar] == nextChar )
if ( PAIRS.contains( prevChar ) && PAIRS[prevChar] == nextChar )
{
setSelection( line, column - 1, line, column + 1 );
removeSelectedText();
Expand Down

0 comments on commit 04290ea

Please sign in to comment.