diff --git a/NEWS.md b/NEWS.md index 8f948d32..574dba5b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,8 @@ Red Panda C++ Version 2.24 - fix: Code completion doesn't work if "min id length to show completion" is not 1. - fix: english typos. (thanks for sangiye0@github) - fix: Goto definition/declaration may choose wrong symbol is multiple files are opened and symbols have the same name. + - fix: "UTF-8 BOM" can't be correctly loaded as project file's encoding. + - fix: Project file's encoding is not correctly updated after converted manually. Red Panda C++ Version 2.23 diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 70acbdb6..e9c3191a 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -337,6 +337,13 @@ void Editor::convertToEncoding(const QByteArray &encoding) mEncodingOption = encoding; setModified(true); save(); + if (mProject) { + PProjectUnit unit = mProject->findUnit(this); + if (unit) { + unit->setEncoding(mEncodingOption); + unit->setRealEncoding(mFileEncoding); + } + } } bool Editor::save(bool force, bool doReparse) { diff --git a/RedPandaIDE/project.cpp b/RedPandaIDE/project.cpp index 11aeff7c..f14a2693 100644 --- a/RedPandaIDE/project.cpp +++ b/RedPandaIDE/project.cpp @@ -242,7 +242,10 @@ void Project::open() newUnit->setOverrideBuildCmd(ini.GetBoolValue(groupName,"OverrideBuildCmd", false)); newUnit->setBuildCmd(fromByteArray(ini.GetValue(groupName,"BuildCmd", ""))); newUnit->setEncoding(ini.GetValue(groupName, "FileEncoding",ENCODING_PROJECT)); - if (QTextCodec::codecForName(newUnit->encoding())==nullptr) { + if (newUnit->encoding()!=ENCODING_UTF16_BOM && + newUnit->encoding()!=ENCODING_UTF8_BOM && + newUnit->encoding()!=ENCODING_UTF32_BOM && + QTextCodec::codecForName(newUnit->encoding())==nullptr) { newUnit->setEncoding(ENCODING_PROJECT); } newUnit->setRealEncoding(ini.GetValue(groupName, "RealEncoding",ENCODING_ASCII));