diff --git a/NEWS.md b/NEWS.md index 0da4ce31..4203d188 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,7 @@ Red Panda C++ Version 1.0.3 - enhancement: shift+ctrl+down/up to move currenlt selection lines up / down - fix: can't compile under linux - enhancement: support Devcie Pixel Ratio ( for linux ) + - fix: crash when editing txt file and input symbol at the beginning of a line Red Panda C++ Version 1.0.2 - enhancement: press tab in column mode won't exit column mode diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 956028b2..41724ce5 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -2001,31 +2001,33 @@ bool Editor::handleSymbolCompletion(QChar key) return false; //todo: better methods to detect current caret type - if (caretX() <= 1) { - if (caretY()>1) { - if (highlighter()->isLastLineCommentNotFinished(lines()->ranges(caretY() - 2).state)) - return false; - if (highlighter()->isLastLineStringNotFinished(lines()->ranges(caretY() - 2).state) - && (key!='\"') && (key!='\'')) - return false; - } - } else { - BufferCoord HighlightPos = BufferCoord{caretX()-1, caretY()}; - // Check if that line is highlighted as comment - PSynHighlighterAttribute Attr; - QString Token; - bool tokenFinished; - SynHighlighterTokenType tokenType; - if (getHighlighterAttriAtRowCol(HighlightPos, Token, tokenFinished, tokenType,Attr)) { - if ((tokenType == SynHighlighterTokenType::Comment) && (!tokenFinished)) - return false; - if ((tokenType == SynHighlighterTokenType::String) && (!tokenFinished) - && (key!='\'') && (key!='\"') && (key!='(') && (key!=')')) - return false; - if (( key=='<' || key =='>') && (mParser && !mParser->isIncludeLine(lineText()))) - return false; - if ((key == '\'') && (Attr->name() == "SYNS_AttrNumber")) - return false; + if (highlighter()) { + if (caretX() <= 1) { + if (caretY()>1) { + if (highlighter()->isLastLineCommentNotFinished(lines()->ranges(caretY() - 2).state)) + return false; + if (highlighter()->isLastLineStringNotFinished(lines()->ranges(caretY() - 2).state) + && (key!='\"') && (key!='\'')) + return false; + } + } else { + BufferCoord HighlightPos = BufferCoord{caretX()-1, caretY()}; + // Check if that line is highlighted as comment + PSynHighlighterAttribute Attr; + QString Token; + bool tokenFinished; + SynHighlighterTokenType tokenType; + if (getHighlighterAttriAtRowCol(HighlightPos, Token, tokenFinished, tokenType,Attr)) { + if ((tokenType == SynHighlighterTokenType::Comment) && (!tokenFinished)) + return false; + if ((tokenType == SynHighlighterTokenType::String) && (!tokenFinished) + && (key!='\'') && (key!='\"') && (key!='(') && (key!=')')) + return false; + if (( key=='<' || key =='>') && (mParser && !mParser->isIncludeLine(lineText()))) + return false; + if ((key == '\'') && (Attr->name() == "SYNS_AttrNumber")) + return false; + } } }