- fix: Result of scope calculation not right if a for statement immediately follows another for statement.

This commit is contained in:
Roy Qu 2023-01-10 19:08:49 +08:00
parent 7324475277
commit 5f75fd97cd
2 changed files with 3 additions and 2 deletions

View File

@ -22,6 +22,7 @@ Red Panda C++ Version 2.8
- fix: Can't save new file using filename with custom suffix. - fix: Can't save new file using filename with custom suffix.
- fix: alt+shift+left/right can't select - fix: alt+shift+left/right can't select
- fix: Input any content will exit column mode. - 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 Red Panda C++ Version 2.7

View File

@ -512,8 +512,8 @@ PStatement CppScopes::findScopeAtLine(int line)
int mid = (start+end)/2; int mid = (start+end)/2;
PCppScope midScope = mScopes[mid]; PCppScope midScope = mScopes[mid];
if (midScope->startLine == line) { if (midScope->startLine == line) {
while (mid-1>=0 && (mScopes[mid-1]->startLine == line)) { while (mid<end && (mScopes[mid+1]->startLine == line)) {
mid--; mid++;
} }
return mScopes[mid]->statement; return mScopes[mid]->statement;
} else if (midScope->startLine > line) { } else if (midScope->startLine > line) {