From 5f75fd97cd8805a1a2e69a630ca389c16902554e Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Tue, 10 Jan 2023 19:08:49 +0800 Subject: [PATCH] - fix: Result of scope calculation not right if a for statement immediately follows another for statement. --- NEWS.md | 1 + RedPandaIDE/parser/parserutils.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) 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) {