Skip to content

Commit

Permalink
Tab key Bug Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
JaDogg committed Dec 14, 2014
1 parent f7d1eb8 commit 71be81b
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions CodeEditor/codeeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,17 +173,21 @@ void CodeEditor::keyPressEvent(QKeyEvent* e)
}
break;
case Qt::Key_Tab:
SelectLineMarginBlock();
{
QString text("");
QStringList lines = this->textCursor().selection().toPlainText().split(QRegExp("\n|\r\n|\r"));
foreach (QString line, lines) {
text.append(" ");
text.append(line);
text.append("\n");
if (this->textCursor().hasSelection()) {
SelectLineMarginBlock();
{
QString text("");
QStringList lines = this->textCursor().selection().toPlainText().split(QRegExp("\n|\r\n|\r"));
foreach (QString line, lines) {
text.append(" ");
text.append(line);
text.append("\n");
}
text.truncate(text.length() - 1);
this->textCursor().insertText(text);
}
text.truncate(text.length() - 1);
this->textCursor().insertText(text);
} else {
this->insertPlainText(" ");
}
break;
case Qt::Key_Enter:
Expand Down

0 comments on commit 71be81b

Please sign in to comment.