From ce06845b362063a48d275073dfed3b9091f37ed4 Mon Sep 17 00:00:00 2001 From: mgrojo Date: Fri, 24 Nov 2017 19:31:47 +0100 Subject: [PATCH] Folding issues related to the Scintilla JSON lexer Applied patch from: https://sourceforge.net/p/scintilla/code/merge-requests/19/ See this thread for info: https://groups.google.com/forum/#!topic/scintilla-interest/w4sW3sM6Cek This is merged into Scintilla, so it might come fixed in a future release. This should solve the folding issue reported in #1173 --- libs/DB4S_PATCH_04 | 24 ++++++++++++++++++++++++ libs/qscintilla/lexers/LexJSON.cpp | 6 ++++-- 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 libs/DB4S_PATCH_04 diff --git a/libs/DB4S_PATCH_04 b/libs/DB4S_PATCH_04 new file mode 100644 index 00000000..ed3fa9d2 --- /dev/null +++ b/libs/DB4S_PATCH_04 @@ -0,0 +1,24 @@ +diff --git a/libs/qscintilla/lexers/LexJSON.cpp b/libs/qscintilla/lexers/LexJSON.cpp +index 9c044e5..6c06061 100644 +--- a/libs/qscintilla/lexers/LexJSON.cpp ++++ b/libs/qscintilla/lexers/LexJSON.cpp +@@ -457,7 +457,9 @@ void SCI_METHOD LexerJSON::Fold(Sci_PositionU startPos, + LexAccessor styler(pAccess); + Sci_PositionU currLine = styler.GetLine(startPos); + Sci_PositionU endPos = startPos + length; +- int currLevel = styler.LevelAt(currLine) & SC_FOLDLEVELNUMBERMASK; ++ int currLevel = SC_FOLDLEVELBASE; ++ if (currLine > 0) ++ currLevel = styler.LevelAt(currLine - 1) >> 16; + int nextLevel = currLevel; + int visibleChars = 0; + for (Sci_PositionU i = startPos; i < endPos; i++) { +@@ -472,7 +474,7 @@ void SCI_METHOD LexerJSON::Fold(Sci_PositionU startPos, + } + } + if (atEOL || i == (endPos-1)) { +- int level = currLevel; ++ int level = currLevel | nextLevel << 16; + if (!visibleChars && options.foldCompact) { + level |= SC_FOLDLEVELWHITEFLAG; + } else if (nextLevel > currLevel) { diff --git a/libs/qscintilla/lexers/LexJSON.cpp b/libs/qscintilla/lexers/LexJSON.cpp index 9c044e52..6c060611 100644 --- a/libs/qscintilla/lexers/LexJSON.cpp +++ b/libs/qscintilla/lexers/LexJSON.cpp @@ -457,7 +457,9 @@ void SCI_METHOD LexerJSON::Fold(Sci_PositionU startPos, LexAccessor styler(pAccess); Sci_PositionU currLine = styler.GetLine(startPos); Sci_PositionU endPos = startPos + length; - int currLevel = styler.LevelAt(currLine) & SC_FOLDLEVELNUMBERMASK; + int currLevel = SC_FOLDLEVELBASE; + if (currLine > 0) + currLevel = styler.LevelAt(currLine - 1) >> 16; int nextLevel = currLevel; int visibleChars = 0; for (Sci_PositionU i = startPos; i < endPos; i++) { @@ -472,7 +474,7 @@ void SCI_METHOD LexerJSON::Fold(Sci_PositionU startPos, } } if (atEOL || i == (endPos-1)) { - int level = currLevel; + int level = currLevel | nextLevel << 16; if (!visibleChars && options.foldCompact) { level |= SC_FOLDLEVELWHITEFLAG; } else if (nextLevel > currLevel) {