- enhancement: reduce memory usage when deciding file type
This commit is contained in:
parent
fcb64a69af
commit
0d45cca2a5
1
NEWS.md
1
NEWS.md
|
@ -13,6 +13,7 @@ Red Panda C++ Version 2.0
|
||||||
- enhancement: Weither double click on the class browser should goto definition/declaration, depends on the current cursor position
|
- enhancement: Weither double click on the class browser should goto definition/declaration, depends on the current cursor position
|
||||||
- enhancement: keep current position in the class browser after contents modified
|
- enhancement: keep current position in the class browser after contents modified
|
||||||
- fix: "." and ".." in included header paths not correctly handled
|
- fix: "." and ".." in included header paths not correctly handled
|
||||||
|
- reduce memory usage when deciding file types
|
||||||
|
|
||||||
Red Panda C++ Version 1.5
|
Red Panda C++ Version 1.5
|
||||||
|
|
||||||
|
|
|
@ -2550,21 +2550,21 @@ bool Editor::handleCodeCompletion(QChar key)
|
||||||
|
|
||||||
void Editor::initParser()
|
void Editor::initParser()
|
||||||
{
|
{
|
||||||
mParser=nullptr;
|
// mParser=nullptr;
|
||||||
// mParser = std::make_shared<CppParser>();
|
mParser = std::make_shared<CppParser>();
|
||||||
// if (mUseCppSyntax) {
|
if (mUseCppSyntax) {
|
||||||
// mParser->setLanguage(ParserLanguage::CPlusPlus);
|
mParser->setLanguage(ParserLanguage::CPlusPlus);
|
||||||
// } else {
|
} else {
|
||||||
// mParser->setLanguage(ParserLanguage::C);
|
mParser->setLanguage(ParserLanguage::C);
|
||||||
// }
|
}
|
||||||
// mParser->setOnGetFileStream(
|
mParser->setOnGetFileStream(
|
||||||
// std::bind(
|
std::bind(
|
||||||
// &EditorList::getContentFromOpenedEditor,pMainWindow->editorList(),
|
&EditorList::getContentFromOpenedEditor,pMainWindow->editorList(),
|
||||||
// std::placeholders::_1, std::placeholders::_2));
|
std::placeholders::_1, std::placeholders::_2));
|
||||||
// resetCppParser(mParser);
|
resetCppParser(mParser);
|
||||||
// mParser->setEnabled(
|
mParser->setEnabled(
|
||||||
// pSettings->codeCompletion().enabled() &&
|
pSettings->codeCompletion().enabled() &&
|
||||||
// (highlighter() && highlighter()->getClass() == QSynedit::HighlighterClass::CppHighlighter));
|
(highlighter() && highlighter()->getClass() == QSynedit::HighlighterClass::CppHighlighter));
|
||||||
}
|
}
|
||||||
|
|
||||||
Editor::QuoteStatus Editor::getQuoteStatus()
|
Editor::QuoteStatus Editor::getQuoteStatus()
|
||||||
|
@ -3458,6 +3458,8 @@ QString Editor::getFileHint(const QString &s, bool fromNext)
|
||||||
|
|
||||||
QString Editor::getParserHint(const QStringList& expression,const QString &/*s*/, int line)
|
QString Editor::getParserHint(const QStringList& expression,const QString &/*s*/, int line)
|
||||||
{
|
{
|
||||||
|
if (!mParser)
|
||||||
|
return "";
|
||||||
// This piece of code changes the parser database, possibly making hints and code completion invalid...
|
// This piece of code changes the parser database, possibly making hints and code completion invalid...
|
||||||
QString result;
|
QString result;
|
||||||
// Exit early, don't bother creating a stream (which is slow)
|
// Exit early, don't bother creating a stream (which is slow)
|
||||||
|
|
|
@ -140,10 +140,9 @@ FileType getFileType(const QString &filename)
|
||||||
if (filename.endsWith(".dat",PATH_SENSITIVITY)) {
|
if (filename.endsWith(".dat",PATH_SENSITIVITY)) {
|
||||||
return FileType::Text;
|
return FileType::Text;
|
||||||
}
|
}
|
||||||
QMimeDatabase db;
|
QFileInfo info(filename);
|
||||||
QMimeType mimeType=db.mimeTypeForFile(filename);
|
if (info.suffix().isEmpty()) {
|
||||||
if (mimeType.isValid() && mimeType.name().startsWith("text/")) {
|
return FileType::Other;
|
||||||
return FileType::Text;
|
|
||||||
}
|
}
|
||||||
return FileType::Other;
|
return FileType::Other;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue