diff --git a/NEWS.md b/NEWS.md index b7583a1d..a5d257e7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,6 +3,9 @@ Red Panda C++ Version 1.0.4 - enhancement: add help link for regular expression in search dialog - enhancement: remember current problem set's filename - enhancement: F1 shorcut opens offcial website + - enhancement: don't auto complete '(', if the next non-space char is neither '(' nor ident char + - enhancement: if a project's unit encoding is the same with project's encoding, don't save its encoding + - fix: files will be saved to default encoding inspite of its original encoding Red Panda C++ Version 1.0.3 - fix: when oj problem grabbed by competitive companion received, diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 8f0e775d..411fb73b 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -228,7 +228,10 @@ void Editor::loadFile(QString filename) { void Editor::saveFile(QString filename) { QFile file(filename); - this->lines()->saveToFile(file,mEncodingOption, + QByteArray encoding = mFileEncoding; + if (mFileEncoding==ENCODING_ASCII) + encoding = mEncodingOption; + this->lines()->saveToFile(file,encoding, pSettings->editor().defaultEncoding(), mFileEncoding); emit fileSaved(filename, mInProject); @@ -797,13 +800,14 @@ void Editor::keyPressEvent(QKeyEvent *event) case '*': handled = handleSymbolCompletion(ch); return; - case '(': - if (caretX()-1>=lineText().length() - || caretX()<=0 - || isSpaceOrRightParenthesis(lineText().at(caretX()-1))) { + case '(': { + QChar nextCh = nextNotspaceChar(caretY()-1,caretX()-1); + qDebug()<': if ((caretX() <= 1) || lineText().isEmpty() || lineText()[caretX() - 2] != '-') { diff --git a/RedPandaIDE/project.cpp b/RedPandaIDE/project.cpp index 33ad6d03..76177e50 100644 --- a/RedPandaIDE/project.cpp +++ b/RedPandaIDE/project.cpp @@ -608,7 +608,8 @@ bool Project::saveUnits() ini.SetLongValue(groupName,"OverrideBuildCmd", unit->overrideBuildCmd()); ini.SetValue(groupName,"BuildCmd", toByteArray(unit->buildCmd())); ini.SetLongValue(groupName,"DetectEncoding", unit->encoding()==ENCODING_AUTO_DETECT); - ini.SetValue(groupName,"FileEncoding", toByteArray(unit->encoding())); + if (unit->encoding() != options().encoding) + ini.SetValue(groupName,"FileEncoding", toByteArray(unit->encoding())); } ini.SetLongValue("Project","UnitCount",count); ini.SaveFile(mFilename.toLocal8Bit()); @@ -927,7 +928,7 @@ PProjectUnit Project::addUnit(const QString &inFileName, PProjectModelNode paren newUnit->setEncoding(e->fileEncoding()); e->setInProject(true); } else { - newUnit->setEncoding(pSettings->editor().defaultEncoding()); + newUnit->setEncoding(options().encoding.toUtf8()); } newUnit->setFolder(getFolderPath(parentNode)); newUnit->setNode(makeNewFileNode(extractFileName(newUnit->fileName()), false, parentNode)); diff --git a/RedPandaIDE/qsynedit/SynEdit.cpp b/RedPandaIDE/qsynedit/SynEdit.cpp index a370dc6b..dca25886 100644 --- a/RedPandaIDE/qsynedit/SynEdit.cpp +++ b/RedPandaIDE/qsynedit/SynEdit.cpp @@ -1100,6 +1100,23 @@ QChar SynEdit::charAt(const BufferCoord &pos) return QChar(0); } +QChar SynEdit::nextNotspaceChar(int line, int ch) +{ + if (ch<0) + return QChar(); + QString s = mLines->getString(line); + if (s.isEmpty()) + return QChar(); + int x=ch; + while (x