Navigation Menu

Skip to content

Commit

Permalink
Handle backticks and stars
Browse files Browse the repository at this point in the history
  • Loading branch information
YoannQDQ authored and nyalldawson committed Jan 10, 2023
1 parent 88a683f commit 6562062
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/gui/codeeditors/qgscodeeditorpython.cpp
Expand Up @@ -41,6 +41,9 @@ namespace
{"'", "'"},
{"\"", "\""}
};

// Only used for selected text
const QStringList SINGLE_CHARS = {"`", "*"};
}

QgsCodeEditorPython::QgsCodeEditorPython( QWidget *parent, const QList<QString> &filenames, Mode mode )
Expand Down Expand Up @@ -309,6 +312,17 @@ void QgsCodeEditorPython::keyPressEvent( QKeyEvent *event )
event->accept();
return;
}
else if ( SINGLE_CHARS.contains( eText ) )
{
int startLine, startPos, endLine, endPos;
getSelection( &startLine, &startPos, &endLine, &endPos );
replaceSelectedText(
QString( "%1%2%1" ).arg( eText ).arg( selectedText() )
);
setSelection( startLine, startPos + 1, endLine, endPos + 1 );
event->accept();
return;
}

// Let QgsCodeEditor handle the keyboard event
return QgsCodeEditor::keyPressEvent( event );
Expand Down

0 comments on commit 6562062

Please sign in to comment.