Skip to content

Commit

Permalink
Better autocompletion list handling
Browse files Browse the repository at this point in the history
  • Loading branch information
YoannQDQ authored and nyalldawson committed Jan 10, 2023
1 parent 660990e commit a888d9c
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions src/gui/codeeditors/qgscodeeditor.cpp
Expand Up @@ -170,7 +170,13 @@ void QgsCodeEditor::focusOutEvent( QFocusEvent *event )
// but only is the auto-completion suggestion list isn't displayed
void QgsCodeEditor::keyPressEvent( QKeyEvent *event )
{
if ( event->key() == Qt::Key_Escape && !isListActive() )
if( isListActive() )
{
QsciScintilla::keyPressEvent( event );
return;
}

if ( event->key() == Qt::Key_Escape )
{
// Shortcut QScintilla and redirect the event to the QWidget handler
QWidget::keyPressEvent( event ); // clazy:exclude=skipped-base-method
Expand All @@ -188,34 +194,22 @@ void QgsCodeEditor::keyPressEvent( QKeyEvent *event )
return;

case Qt::Key_Down:

if ( !isListActive() )
{
showPreviousCommand();
updatePrompt();
return;
}
break;
showPreviousCommand();
updatePrompt();
return;

case Qt::Key_Up:

if ( !isListActive() )
{
showNextCommand();
updatePrompt();
return;
}
break;
showNextCommand();
updatePrompt();
return;

default:
break;
}
QsciScintilla::keyPressEvent( event );
}
else
{
QsciScintilla::keyPressEvent( event );
}

QsciScintilla::keyPressEvent( event );

}

void QgsCodeEditor::contextMenuEvent( QContextMenuEvent *event )
Expand Down

0 comments on commit a888d9c

Please sign in to comment.