mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2026-02-19 18:16:35 +01:00
SynEdit: XML/Html-Highlighter, fix closing multiple folds/tags on one line. Issue #30912
This commit is contained in:
parent
c589e9e1e3
commit
1340271fb7
@ -220,6 +220,9 @@ begin
|
||||
if i = 0 then begin
|
||||
i := LineIndex - 1;
|
||||
lvl := FoldBlockEndLevel(i);
|
||||
k := CurrentCodeFoldBlockLevel; //CodeFoldRange.CodeFoldStackSize;
|
||||
if k < lvl then
|
||||
lvl := k;
|
||||
while i >= 0 do begin
|
||||
if FoldBlockMinLevel(i) < lvl then begin
|
||||
LInfo := TSynHighlighterXmlRangeList(CurrentRanges).XmlRangeInfo[i].ElementOpenList;
|
||||
@ -246,7 +249,7 @@ begin
|
||||
FXmlRangeInfo.ElementCloseList[FXmlRangeInfoClosePos] := cnt;
|
||||
FXmlRangeInfoChanged := true;
|
||||
end;
|
||||
end else begin // append - modified will be deteced by the new length
|
||||
end else begin // append - modified will be detected by the new length
|
||||
SetLength(FXmlRangeInfo.ElementCloseList, FXmlRangeInfoClosePos + 10);
|
||||
FXmlRangeInfo.ElementCloseList[FXmlRangeInfoClosePos] := cnt;
|
||||
end;
|
||||
|
||||
@ -15,9 +15,11 @@ type
|
||||
THighlightXml = class(TTestBaseHighlighterFoldBase)
|
||||
protected
|
||||
function CreateTheHighLighter: TSynCustomFoldHighlighter; override;
|
||||
function TestTextFold1: TStringArray;
|
||||
published
|
||||
procedure TestXml;
|
||||
end;
|
||||
procedure TestFold;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
@ -26,6 +28,30 @@ begin
|
||||
Result := TSynXMLSyn.Create(nil);
|
||||
end;
|
||||
|
||||
function THighlightXml.TestTextFold1: TStringArray;
|
||||
begin
|
||||
SetLength(Result, 16);
|
||||
|
||||
Result[0] := '<code>';
|
||||
Result[1] := '<font size=3 face="Courier New">';
|
||||
Result[2] := '<span style="color: black;">';
|
||||
Result[3] := '</span></font>';
|
||||
Result[4] := '</code>';
|
||||
|
||||
Result[5] := '<code><div><span></span>';
|
||||
Result[6] := '<font>';
|
||||
Result[7] := '<span><p><p></p><div><div></div>';
|
||||
Result[8] := '</div><p></p></p></span></font></div>';
|
||||
Result[9] := '</code>';
|
||||
|
||||
Result[10] := '<code><div><span></span>';
|
||||
Result[11] := '<font>';
|
||||
Result[12] := '<span><p><p></p><div><div></div>';
|
||||
Result[13] := '</div><p></p></p></span></font></div><div>'; // close and open line
|
||||
Result[14] := '</div></code>';
|
||||
Result[15] := '';
|
||||
end;
|
||||
|
||||
procedure THighlightXml.TestXml;
|
||||
function TestText: TStringArray;
|
||||
begin
|
||||
@ -68,6 +94,35 @@ begin
|
||||
|
||||
end;
|
||||
|
||||
procedure THighlightXml.TestFold;
|
||||
begin
|
||||
ReCreateEdit;
|
||||
SetLines(TestTextFold1);
|
||||
|
||||
CheckFoldOpenCounts('f1', [1,1,1,0,0, 2,1,3,0,0, 2,1,3,1,0]);
|
||||
CheckFoldLengths ('f1', [
|
||||
ExpVLine(0,[4]),
|
||||
ExpVLine(1,[2]),
|
||||
ExpVLine(2,[1]),
|
||||
|
||||
ExpVLine(5,[4,3]),
|
||||
ExpVLine(6,[2]),
|
||||
ExpVLine(7,[1,1,1]),
|
||||
|
||||
ExpVLine(10,[4,3-1]),
|
||||
ExpVLine(11,[2-1]),
|
||||
//ExpVLine(12,[1-1,1-1,1-1]),
|
||||
ExpVLine(13,[1])
|
||||
|
||||
]);
|
||||
CheckFoldEndLines ('simple', [
|
||||
ExpVLine(0,[4]),
|
||||
ExpVLine(1,[3]),
|
||||
ExpVLine(2,[3])
|
||||
]);
|
||||
|
||||
end;
|
||||
|
||||
|
||||
|
||||
initialization
|
||||
|
||||
Loading…
Reference in New Issue
Block a user