diff --git a/NEWS.md b/NEWS.md index a655c66a..54c72da3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -22,6 +22,7 @@ Red Panda C++ Version 2.8 - fix: Can't save new file using filename with custom suffix. - fix: alt+shift+left/right can't select - fix: Input any content will exit column mode. + - fix: Result of scope calculation not right if a for statement immediately follows another for statement. Red Panda C++ Version 2.7 diff --git a/RedPandaIDE/parser/parserutils.cpp b/RedPandaIDE/parser/parserutils.cpp index 8132a358..60a3e7dd 100644 --- a/RedPandaIDE/parser/parserutils.cpp +++ b/RedPandaIDE/parser/parserutils.cpp @@ -512,8 +512,8 @@ PStatement CppScopes::findScopeAtLine(int line) int mid = (start+end)/2; PCppScope midScope = mScopes[mid]; if (midScope->startLine == line) { - while (mid-1>=0 && (mScopes[mid-1]->startLine == line)) { - mid--; + while (midstartLine == line)) { + mid++; } return mScopes[mid]->statement; } else if (midScope->startLine > line) {