Skip to content

Commit 59731d7

Browse files
committed
triage: set error line properly
1 parent f388c77 commit 59731d7

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

gui/codeeditor.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ class CodeEditor : public QPlainTextEdit {
5555
void lineNumberAreaPaintEvent(QPaintEvent *event);
5656
int lineNumberAreaWidth();
5757

58+
/**
59+
* Set source code to show, goto error line and highlight that line.
60+
* \param code The source code.
61+
* \param errorLine line number
62+
* \param symbols the related symbols, these are marked
63+
*/
5864
void setError(const QString &code, int errorLine, const QStringList &symbols);
5965

6066
protected:

tools/triage/mainwindow.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,5 @@ void MainWindow::showResult(QListWidgetItem *item)
134134
f.open(QIODevice::ReadOnly | QIODevice::Text);
135135
QTextStream textStream(&f);
136136
const QString fileData = textStream.readAll();
137-
ui->code->setPlainText(fileData);
138-
for (int pos = 0, line = 1; pos < fileData.size(); ++pos) {
139-
if (fileData[pos] == '\n') {
140-
++line;
141-
if (line == lineNumber) {
142-
QTextCursor textCursor = ui->code->textCursor();
143-
textCursor.setPosition(pos+1);
144-
ui->code->setTextCursor(textCursor);
145-
ui->code->centerCursor();
146-
break;
147-
}
148-
}
149-
}
137+
ui->code->setError(fileData, lineNumber, QStringList());
150138
}

0 commit comments

Comments
 (0)