Skip to content
Snippets Groups Projects
Commit 030525fe authored by Marco Biasini's avatar Marco Biasini
Browse files

better fix for BZDNG-238, this time including the backspace key

parent 1d2d0424
Branches
Tags
No related merge requests found
......@@ -474,6 +474,7 @@ void PythonShellWidget::OnExecuteStateEntered()
set_block_type_(block_edit_start_,textCursor().block(),BLOCKTYPE_CODE);
insertPlainText(QString(QChar::ParagraphSeparator));
QString command=GetCommand();
QString command_trimmed=command.trimmed();
if (command_trimmed.size()>0) {
unsigned int id=PythonInterpreter::Instance().RunCommand(command);
......@@ -482,7 +483,6 @@ void PythonShellWidget::OnExecuteStateEntered()
insertPlainText(QString(QChar::ParagraphSeparator));
}
block_edit_start_=textCursor().block();
std::cout << block_edit_start_.isValid() << std::endl;
}
......@@ -739,22 +739,29 @@ void PythonShellWidget::keyPressEvent(QKeyEvent* event)
{
// BZDNG-238
// Letting Qt do the handling of the backspace key leads to a crash when
// multiline block mode and doing the following:
// editing a multiline block mode and doing the following:
//
// (a) Hit Ctrl+A
// (b) Hit Backspace
// (b) Hit Backspace|Delete
// (c) Hit Return
//
// If we emulate the deletion of the text manually all is fine.
if (event->key()==Qt::Key_Backspace) {
if (event->key()==Qt::Key_Backspace || event->key()==Qt::Key_Delete) {
QTextCursor cursor=this->textCursor();
if (cursor.hasSelection()) {
cursor.removeSelectedText();
} else {
if (cursor.position()>this->GetEditStartBlock().position()) {
cursor.deletePreviousChar();
if (event->key()==Qt::Key_Backspace) {
cursor.deletePreviousChar();
} else {
cursor.deleteChar();
}
}
}
QTextCursor tc=this->textCursor();
tc.setPosition(block_edit_start_.position());
block_edit_start_=tc.block();
event->accept();
return;
}
......@@ -767,9 +774,11 @@ void PythonShellWidget::keyPressEvent(QKeyEvent* event)
}
}
if (this->handle_custom_commands_(event)){
event->accept();
return;
}
if (this->handle_completion_(event)){
event->accept();
return;
}
QPlainTextEdit::keyPressEvent(event);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment