Gui: avoid code duplication in PythonEditor
This commit is contained in:
@@ -243,27 +243,7 @@ void PythonEditor::onComment()
|
||||
|
||||
void PythonEditor::onUncomment()
|
||||
{
|
||||
QTextCursor cursor = textCursor();
|
||||
int selStart = cursor.selectionStart();
|
||||
int selEnd = cursor.selectionEnd();
|
||||
QTextBlock block;
|
||||
cursor.beginEditBlock();
|
||||
for (block = document()->begin(); block.isValid(); block = block.next()) {
|
||||
int pos = block.position();
|
||||
int off = block.length()-1;
|
||||
// at least one char of the block is part of the selection
|
||||
if ( pos >= selStart || pos+off >= selStart) {
|
||||
if ( pos+1 > selEnd )
|
||||
break; // end of selection reached
|
||||
if (block.text().startsWith(QLatin1String("#"))) {
|
||||
cursor.setPosition(block.position());
|
||||
cursor.deleteChar();
|
||||
selEnd--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cursor.endEditBlock();
|
||||
remove(QStringLiteral("#"));
|
||||
}
|
||||
|
||||
void PythonEditor::onExecuteInConsole()
|
||||
|
||||
Reference in New Issue
Block a user