diff --git a/NEWS.md b/NEWS.md index 946d9df6..a40760f2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -16,7 +16,8 @@ Red Panda C++ Version 0.13.3 - fix: Undo in the editor will lose line indents when no highlighter is assigned (the editing file is a not c/cpp source file); - enhancement: highlighter for GLSL (OpenGL Shading Language) - add a new template for raylib shader apps - + - fix: project files' charset settings doesn't work correctly + Red Panda C++ Version 0.13.2 - fix: "delete and exit" button in the environtment / folder option page doesn't work correctly - fix: crash when closing the options dialog under Ubuntu 20.04 LTS ( no memory leak now) diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 739755f9..d3d3fef9 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -394,6 +394,8 @@ const QByteArray& Editor::encodingOption() const noexcept{ return mEncodingOption; } void Editor::setEncodingOption(const QByteArray& encoding) noexcept{ + if (mEncodingOption == encoding) + return; mEncodingOption = encoding; if (!isNew()) loadFile(); diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index a3141131..535bf76c 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -980,7 +980,8 @@ void MainWindow::openFile(const QString &filename, QTabWidget* page) unit = mProject->findUnitByFilename(filename); } bool inProject = (mProject && unit); - editor = mEditorList->newEditor(filename,ENCODING_AUTO_DETECT, + QByteArray encoding = unit ? unit->encoding() : ENCODING_AUTO_DETECT; + editor = mEditorList->newEditor(filename,encoding, inProject, false, page); if (mProject) { mProject->associateEditorToUnit(editor,unit); @@ -2011,7 +2012,8 @@ void MainWindow::loadLastOpens() unit = mProject->findUnitByFilename(editorFilename); } bool inProject = (mProject && unit); - Editor * editor = mEditorList->newEditor(editorFilename,ENCODING_AUTO_DETECT,inProject,false,page); + QByteArray encoding = unit ? unit->encoding() : ENCODING_AUTO_DETECT; + Editor * editor = mEditorList->newEditor(editorFilename, encoding, inProject,false,page); if (mProject) { mProject->associateEditorToUnit(editor,unit); } diff --git a/RedPandaIDE/project.cpp b/RedPandaIDE/project.cpp index a2d812e3..bb402939 100644 --- a/RedPandaIDE/project.cpp +++ b/RedPandaIDE/project.cpp @@ -1760,7 +1760,12 @@ const QByteArray &ProjectUnit::encoding() const void ProjectUnit::setEncoding(const QByteArray &newEncoding) { - mEncoding = newEncoding; + if (mEncoding != newEncoding) { + if (mEditor) { + mEditor->setEncodingOption(newEncoding); + } + mEncoding = newEncoding; + } } bool ProjectUnit::modified() const