aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/LexCPP.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/LexCPP.cxx')
-rw-r--r--src/LexCPP.cxx9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/LexCPP.cxx b/src/LexCPP.cxx
index 512581807..c5e55df8b 100644
--- a/src/LexCPP.cxx
+++ b/src/LexCPP.cxx
@@ -332,15 +332,20 @@ static void FoldCppDoc(unsigned int startPos, int length, int initStyle, WordLis
Accessor &styler) {
bool foldComment = styler.GetPropertyInt("fold.comment");
bool foldCompact = styler.GetPropertyInt("fold.compact", 1);
- unsigned int lengthDoc = startPos + length;
+ unsigned int endPos = startPos + length;
int visibleChars = 0;
int lineCurrent = styler.GetLine(startPos);
+ // Move back one line in case deletion wrecked current line fold state
+ if (lineCurrent > 0) {
+ lineCurrent--;
+ startPos = styler.LineStart(lineCurrent);
+ }
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
int levelCurrent = levelPrev;
char chNext = styler[startPos];
int styleNext = styler.StyleAt(startPos);
int style = initStyle;
- for (unsigned int i = startPos; i < lengthDoc; i++) {
+ for (unsigned int i = startPos; i < endPos; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
int stylePrev = style;