Skip to content

Commit

Permalink
TestLexers failed to find per-line folding bugs because it reused the…
Browse files Browse the repository at this point in the history
… document and

lexer object from successful whole document fold for the per-line fold.
Fixed by creating a new document and lexer for the per-line lexing and folding.
This showed there are problems with the current Dart, F#, and Julia folders as well as
the new Zig lexer in #267.
  • Loading branch information
nyamatongwe committed Sep 13, 2024
1 parent e0f045a commit 3ace72f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
15 changes: 10 additions & 5 deletions test/TestLexers.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -897,17 +897,22 @@ bool TestFile(const std::filesystem::path &path, const PropertyMap &propertyMap)
const std::optional<int> perLineDisable = propertyMap.GetPropertyValue("testlexers.per.line.disable");
const bool disablePerLineTests = perLineDisable.value_or(false);

plex->Release();

// Test line by line lexing/folding
if (success && !disablePerLineTests) {
doc.Set(text);
StyleLineByLine(doc, plex);
const auto [styledTextNewPerLine, foldedTextNewPerLine] = MarkedAndFoldedDocument(pdoc);
TestDocument docPerLine;
docPerLine.Set(text);
Scintilla::ILexer5 *plexPerLine = Lexilla::MakeLexer(*language);
if (!SetProperties(plexPerLine, *language, propertyMap, path)) {
return false;
}
StyleLineByLine(docPerLine, plexPerLine);
const auto [styledTextNewPerLine, foldedTextNewPerLine] = MarkedAndFoldedDocument(&docPerLine);
success = success && CheckSame(styledText, styledTextNewPerLine, "per-line styles", suffixStyled, path);
success = success && CheckSame(foldedText, foldedTextNewPerLine, "per-line folds", suffixFolded, path);
}

plex->Release();

if (success) {
Scintilla::ILexer5 *plexCRLF = Lexilla::MakeLexer(*language);
SetProperties(plexCRLF, *language, propertyMap, path.filename().string());
Expand Down
2 changes: 2 additions & 0 deletions test/examples/dart/SciTE.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ keywords3.*.dart=fBigInt Comparable Comparator Completer DateTime Deprecated \
SocketException SplayTreeMap SplayTreeSet StackTrace Stopwatch Stream String \
StringBuffer StringSink Symbol SystemHash Timer Type Uri UriData WeakReference
keywords4.*.dart=Spacecraft

testlexers.per.line.disable=1
2 changes: 2 additions & 0 deletions test/examples/fsharp/SciTE.properties
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ uint uint8 uint16 uint32 uint64 unit void voidptr voption

fold.fsharp.preprocessor=1
fold.comment=1

testlexers.per.line.disable=1
1 change: 1 addition & 0 deletions test/examples/julia/SciTE.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ lexer.*.jl=julia
keywords.*.jl=const end for function in where
keywords2.*.jl=Int Number
keywords3.*.jl=true
testlexers.per.line.disable=1

0 comments on commit 3ace72f

Please sign in to comment.