diff --git a/NEWS.md b/NEWS.md index b49ad0b4..226faaee 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,6 +3,7 @@ Version 0.6.3 - fix: can't copy contents in a readonly editor - fix: project's file not correctly syntaxed when open in editor - libturtle update: add fill() / setBackgroundColor() /setBackgroundImage() functions + - fix: code fold calculation not correct, when editing code Version 0.6.2 - fix: The Enter key in the numpad doesn't work diff --git a/RedPandaIDE/qsynedit/SynEdit.cpp b/RedPandaIDE/qsynedit/SynEdit.cpp index bf178471..cf906ccc 100644 --- a/RedPandaIDE/qsynedit/SynEdit.cpp +++ b/RedPandaIDE/qsynedit/SynEdit.cpp @@ -2831,8 +2831,14 @@ int SynEdit::scanFrom(int Index, int canStopIndex) iRange = mHighlighter->getRangeState(); if (Result > canStopIndex){ if (mLines->ranges(Result).state == iRange.state - ) + && mLines->ranges(Result).braceLevel == iRange.braceLevel + && mLines->ranges(Result).parenthesisLevel == iRange.parenthesisLevel + && mLines->ranges(Result).bracketLevel == iRange.bracketLevel + ) { + if (mUseCodeFolding) + rescan(); return Result;// avoid the final Decrement + } } mLines->setRange(Result,iRange, mHighlighter->getLeftBraces(), mHighlighter->getRightBraces()); @@ -5761,7 +5767,7 @@ void SynEdit::onLinesDeleted(int index, int count) if (mUseCodeFolding) foldOnListDeleted(index + 1, count); if (mHighlighter && mLines->count() > 0) - scanFrom(index-1, index+1); + scanFrom(index, index+1); invalidateLines(index + 1, INT_MAX); invalidateGutterLines(index + 1, INT_MAX); } @@ -5773,7 +5779,7 @@ void SynEdit::onLinesInserted(int index, int count) if (mHighlighter && mLines->count() > 0) { // int vLastScan = index; // do { - scanFrom(index-1, index+2+count); + scanFrom(index, index+count); // vLastScan++; // } while (vLastScan < index + count) ; }