- fix: auto syntax check doesn't work for new files

- change: don't auto jump to the first syntax error location when compile
This commit is contained in:
Roy Qu 2022-04-07 21:35:09 +08:00
parent 7e284b98f2
commit 01662a95d1
4 changed files with 46 additions and 48 deletions

View File

@ -8,6 +8,8 @@ Red Panda C++ Version 1.0.3
- fix: crash when editing txt file and input symbol at the beginning of a line
- fix: ctrl+shift+end doesn't select
- fix: don't show tips in the editor, when selecting by mouse
- fix: auto syntax check doesn't work for new files
- change: don't auto jump to the first syntax error location when compile
Red Panda C++ Version 1.0.2
- enhancement: press tab in column mode won't exit column mode

View File

@ -32,9 +32,6 @@ HighlighterManager::HighlighterManager()
PSynHighlighter HighlighterManager::getHighlighter(const QString &filename)
{
if (filename.isEmpty() || filename.startsWith(QObject::tr("untitled"))) {
return getCppHighlighter();
} else {
QFileInfo info(filename);
QString suffix = info.suffix();
if (suffix.isEmpty() || suffix == "c" || suffix == "cpp" || suffix == "cxx"
@ -46,7 +43,6 @@ PSynHighlighter HighlighterManager::getHighlighter(const QString &filename)
} else if (suffix == "vs" || suffix == "fs" || suffix == "frag") {
return getGLSLHighlighter();
}
}
return PSynHighlighter();
}

View File

@ -1115,7 +1115,7 @@ bool Editor::event(QEvent *event)
if (pMainWindow->functionTip()->isVisible()) {
pMainWindow->functionTip()->hide();
}
QToolTip::showText(mapToGlobal(helpEvent->pos()),hint);
QToolTip::showText(mapToGlobal(helpEvent->pos()),hint,this);
event->ignore();
} else {
updateMouseCursor();
@ -1618,7 +1618,7 @@ void Editor::onTipEvalValueReady(const QString& value)
} else {
newValue = value;
}
QToolTip::showText(QCursor::pos(), mCurrentDebugTipWord + " = " + newValue);
QToolTip::showText(QCursor::pos(), mCurrentDebugTipWord + " = " + newValue, this);
}
disconnect(pMainWindow->debugger(), &Debugger::evalValueReady,
this, &Editor::onTipEvalValueReady);
@ -1753,7 +1753,11 @@ QStringList Editor::getExpressionAtPosition(
int ch = pos.Char-1;
int symbolMatchingLevel = 0;
LastSymbolType lastSymbolType=LastSymbolType::None;
PSynHighlighter highlighter = highlighterManager.getHighlighter(mFilename);
PSynHighlighter highlighter;
if (isNew())
highlighter = highlighterManager.getCppHighlighter();
else
highlighter = highlighterManager.getHighlighter(mFilename);
if (!highlighter)
return result;
while (true) {

View File

@ -1446,6 +1446,7 @@ void MainWindow::checkSyntaxInBack(Editor *e)
// if not devEditor.AutoCheckSyntax then
// Exit;
//not c or cpp file
if (!e->isNew()) {
FileType fileType = getFileType(e->filename());
if (fileType != FileType::CSource
&& fileType != FileType::CppSource
@ -1453,6 +1454,7 @@ void MainWindow::checkSyntaxInBack(Editor *e)
&& fileType != FileType::CppHeader
)
return;
}
if (mCompilerManager->backgroundSyntaxChecking())
return;
if (mCompilerManager->compiling())
@ -4546,22 +4548,18 @@ void MainWindow::onCompileFinished(bool isCheckSyntax)
}
}
// Close it if there's nothing to show
if (isCheckSyntax) {
// check syntax in back, don't change message panel
} else if (
(ui->tableIssues->count() == 0)
) {
} else if (ui->tableIssues->count() == 0) {
// Close it if there's nothing to show
if (ui->tabMessages->currentIndex() == i)
openCloseBottomPanel(false);
// Or open it if there is anything to show
} else {
if (ui->tableIssues->count() > 0) {
if (ui->tabMessages->currentIndex() != i) {
ui->tabMessages->setCurrentIndex(i);
}
openCloseBottomPanel(true);
}
}
Editor * e = mEditorList->getEditor();
if (e!=nullptr) {
@ -4590,28 +4588,26 @@ void MainWindow::onCompileFinished(bool isCheckSyntax)
mCompileSuccessionTask.reset();
// Jump to problem location, sorted by significance
} else if ((mCompilerManager->compileIssueCount() > 0) && (!mCheckSyntaxInBack)) {
bool hasError = false;
// First try to find errors
for (int i=0;i<ui->tableIssues->count();i++) {
PCompileIssue issue = ui->tableIssues->issue(i);
if (issue->type == CompileIssueType::Error) {
if (e && e->filename() != issue->filename)
continue;
ui->tableIssues->selectRow(i);
QModelIndex index =ui->tableIssues->model()->index(i,0);
emit ui->tableIssues->doubleClicked(index);
ui->tabIssues->setFocus();
hasError = true;
break;
}
}
if (!hasError) {
// Then try to find warnings
for (int i=0;i<ui->tableIssues->count();i++) {
PCompileIssue issue = ui->tableIssues->issue(i);
if (issue->type == CompileIssueType::Warning) {
if (e && e->filename() != issue->filename)
continue;
ui->tableIssues->selectRow(i);
QModelIndex index =ui->tableIssues->model()->index(i,0);
emit ui->tableIssues->doubleClicked(index);
ui->tabIssues->setFocus();
break;
}
}
}
}