- 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: crash when editing txt file and input symbol at the beginning of a line
- fix: ctrl+shift+end doesn't select - fix: ctrl+shift+end doesn't select
- fix: don't show tips in the editor, when selecting by mouse - 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 Red Panda C++ Version 1.0.2
- enhancement: press tab in column mode won't exit column mode - enhancement: press tab in column mode won't exit column mode

View File

@ -32,20 +32,16 @@ HighlighterManager::HighlighterManager()
PSynHighlighter HighlighterManager::getHighlighter(const QString &filename) PSynHighlighter HighlighterManager::getHighlighter(const QString &filename)
{ {
if (filename.isEmpty() || filename.startsWith(QObject::tr("untitled"))) { QFileInfo info(filename);
QString suffix = info.suffix();
if (suffix.isEmpty() || suffix == "c" || suffix == "cpp" || suffix == "cxx"
|| suffix == "cc" || suffix == "h" || suffix == "hpp"
|| suffix == "hxx" || suffix == "hh" || suffix == "C"
|| suffix == "CPP" || suffix =="H" || suffix == "c++"
|| suffix == "h++") {
return getCppHighlighter(); return getCppHighlighter();
} else { } else if (suffix == "vs" || suffix == "fs" || suffix == "frag") {
QFileInfo info(filename); return getGLSLHighlighter();
QString suffix = info.suffix();
if (suffix.isEmpty() || suffix == "c" || suffix == "cpp" || suffix == "cxx"
|| suffix == "cc" || suffix == "h" || suffix == "hpp"
|| suffix == "hxx" || suffix == "hh" || suffix == "C"
|| suffix == "CPP" || suffix =="H" || suffix == "c++"
|| suffix == "h++") {
return getCppHighlighter();
} else if (suffix == "vs" || suffix == "fs" || suffix == "frag") {
return getGLSLHighlighter();
}
} }
return PSynHighlighter(); return PSynHighlighter();
} }

View File

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

View File

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