573
797
AssertEquals(FoldedView.Count, 4999-2);
800
{%region Text7 fold at indes, skip, ...}
801
(* Arguments for (Un)FoldAt* (Line, ViewPos, TextIndex):
802
- ColumnIndex (0-based)
803
Can be negative, to access the highest(-1) available, 2nd highest(-2) ...
804
If negative, count points downward
805
- ColCount = 0 => all
806
- Skip => Do not count nodes that are already in the desired state
807
(or can not archive the desired state: e.g. can not hide)
808
- AVisibleLines: 0 = Hide / 1 = Fold
810
TstSetText('Text7 fold at indes, skip, ...', TestText7);
812
for i := 0 to 1 do begin
813
PushBaseName('X='+IntToStr(i));
815
TstFold('fold one col (pos): 0,1,x', 3, 0, 1, i=0, 1, [0, 1, 2, 3, 19, 20, 21, 22, 23, 24, 25]);
817
TstFold('fold one col (pos): 1,1,x', 3, 1, 1, i=0, 1, [0, 1, 2, 3, 17,18,19, 20, 21, 22, 23, 24, 25]);
819
TstFold('fold one col (pos): 2,1,x', 3, 2, 1, i=0, 1, [0, 1, 2, 3, 15,16,17,18,19, 20, 21, 22, 23, 24, 25]);
821
TstFold('fold one col (pos): 3,1,x', 3, 3, 1, i=0, 1, [0, 1, 2, 3, 13,14,15,16,17,18,19, 20, 21, 22, 23, 24, 25]);
823
TstFold('NOT fold one col (pos): 4,1,x', 3, 4, 1, i=0, 1, [0, 1, 2, 3, 4,5,6,7,8,9,10,11,12, 13,14,15,16,17,18,19, 20, 21, 22, 23, 24, 25]);
826
TstFold('fold one col (neg): -4,1,x', 3, -4, 1, i=0, 1, [0, 1, 2, 3, 19, 20, 21, 22, 23, 24, 25]);
828
TstFold('fold one col (neg): -3,1,x', 3, -3, 1, i=0, 1, [0, 1, 2, 3, 17,18,19, 20, 21, 22, 23, 24, 25]);
830
TstFold('fold one col (neg): -2,1,x', 3, -2, 1, i=0, 1, [0, 1, 2, 3, 15,16,17,18,19, 20, 21, 22, 23, 24, 25]);
832
TstFold('fold one col (neg): -1,1,x', 3, -1, 1, i=0, 1, [0, 1, 2, 3, 13,14,15,16,17,18,19, 20, 21, 22, 23, 24, 25]);
834
TstFold('NOT fold one col (neg): -5,1,x', 3, -5, 1, i=0, 1, [0, 1, 2, 3, 4,5,6,7,8,9,10,11,12, 13,14,15,16,17,18,19, 20, 21, 22, 23, 24, 25]);
837
DoAutoFoldDescTestsReadOnly := DoAutoFoldDescTests;
838
DoAutoFoldDescTests := False;
839
// SKIP, if DoAutoFoldDescTests, since fold-info-apply checks for correct node type, and this code force hide.
842
TstFold('hide one col (pos): 0,1,x', 3, 0, 1, i=0, 0, [0, 1, 2, 19, 20, 21, 22, 23, 24, 25]);
844
TstFold('hide one col (pos): 1,1,x', 3, 1, 1, i=0, 0, [0, 1, 2, 17,18,19, 20, 21, 22, 23, 24, 25]);
846
TstFold('hide one col (pos): 2,1,x', 3, 2, 1, i=0, 0, [0, 1, 2, 15,16,17,18,19, 20, 21, 22, 23, 24, 25]);
848
TstFold('hide one col (pos): 3,1,x', 3, 3, 1, i=0, 0, [0, 1, 2, 13,14,15,16,17,18,19, 20, 21, 22, 23, 24, 25]);
850
TstFold('NOT hide one col (pos): 4,1,x', 3, 4, 1, i=0, 0, [0, 1, 2, 3, 4,5,6,7,8,9,10,11,12, 13,14,15,16,17,18,19, 20, 21, 22, 23, 24, 25]);
853
TstFold('hide all-after col (pos): 0,1,x', 3, 0, 0, i=0, 0, [0, 1, 2, 19, 20, 21, 22, 23, 24, 25]);
855
TstFold('hide all-after col (pos): 1,1,x', 3, 1, 0, i=0, 0, [0, 1, 2, 17,18,19, 20, 21, 22, 23, 24, 25]);
857
TstFold('hide all-after col (pos): 2,1,x', 3, 2, 0, i=0, 0, [0, 1, 2, 15,16,17,18,19, 20, 21, 22, 23, 24, 25]);
859
TstFold('hide all-after col (pos): 3,1,x', 3, 3, 0, i=0, 0, [0, 1, 2, 13,14,15,16,17,18,19, 20, 21, 22, 23, 24, 25]);
861
TstFold('NOT hide all-after col (pos): 4,1,x', 3, 4, 1, i=0, 0, [0, 1, 2, 3, 4,5,6,7,8,9,10,11,12, 13,14,15,16,17,18,19, 20, 21, 22, 23, 24, 25]);
863
DoAutoFoldDescTests := DoAutoFoldDescTestsReadOnly;
871
{%region 1st:: 0,1,F}
872
// 1st:: 0,1,F // SKIP=False
873
SynEdit.UnfoldAll; PushBaseName('(1st:: 0,1,F / 2nd:: x=1 no-sk c=1)');
874
TstFold (' fold pre-one col (pos): 0,1,F', 3, 0, 1, False, 1, [0,1,2,3, 19, 20, 21, 22, 23, 24, 25]);
875
TstFold (' fold 2nd col (pos/no-sk): 1,1,F', 3, 1, 1, False, 1, [0,1,2,3, 19, 20, 21, 22, 23, 24, 25]);
876
TstUnFold('UNfold 1st col (pos/no-sk): 0,1,F', 3, 0, 1, False, 1, [0,1,2,3, 17,18,19, 20, 21, 22, 23, 24, 25]);
878
SynEdit.UnfoldAll; PushBaseName('(1st:: 0,1,F / 2nd:: x=2 no-sk c=1)');
879
TstFold (' fold pre-one col (pos): 0,1,F', 3, 0, 1, False, 1, [0,1,2,3, 19, 20, 21, 22, 23, 24, 25]);
880
TstFold (' fold 3rd col (pos/no-sk): 2,1,F', 3, 2, 1, False, 1, [0,1,2,3, 19, 20, 21, 22, 23, 24, 25]);
881
TstUnFold('UNfold 1st col (pos/no-sk): 0,1,F', 3, 0, 1, False, 1, [0,1,2,3, 15,16,17,18,19, 20, 21, 22, 23, 24, 25]);
883
SynEdit.UnfoldAll; PushBaseName('(1st:: 0,1,F / 2nd:: x=3 no-sk c=1)');
884
TstFold (' fold pre-one col (pos): 0,1,F', 3, 0, 1, False, 1, [0,1,2,3, 19, 20, 21, 22, 23, 24, 25]);
885
TstFold (' fold 4th col (pos/no-sk): 3,1,F', 3, 3, 1, False, 1, [0,1,2,3, 19, 20, 21, 22, 23, 24, 25]);
886
TstUnFold('UNfold 1st col (pos/no-sk): 0,1,F', 3, 0, 1, False, 1, [0,1,2,3, 13,14,15,16,17,18,19, 20, 21, 22, 23, 24, 25]);
888
// 1st:: 0,1,F // SKIP=True
889
SynEdit.UnfoldAll; PopPushBaseName('(1st:: 0,1,F / 2nd:: x=0 skip c=1)');
890
TstFold (' fold pre-one col (pos): 0,1,F', 3, 0, 1, False, 1, [0,1,2,3, 19, 20, 21, 22, 23, 24, 25]);
891
TstFold (' fold 2nd col (pos/skip): 0,1,T', 3, 0, 1, True, 1, [0,1,2,3, 19, 20, 21, 22, 23, 24, 25]);
892
// TstUnFold('UNfold 1st col (pos/no-sk): 0,1,F', 3, 0, 1, False, 1, [0,1,2,3, 17,18,19, 20, 21, 22, 23, 24, 25]);
894
SynEdit.UnfoldAll; PopPushBaseName('(1st:: 0,1,F / 2nd:: x=1 skip c=1)');
895
TstFold (' fold pre-one col (pos): 0,1,F', 3, 0, 1, False, 1, [0,1,2,3, 19, 20, 21, 22, 23, 24, 25]);
896
TstFold (' fold 3rd col (pos/skip): 1,1,T', 3, 1, 1, True, 1, [0,1,2,3, 19, 20, 21, 22, 23, 24, 25]);
897
// TstUnFold('UNfold 1st col (pos/no-sk): 0,1,F', 3, 0, 1, False, 1, [0,1,2,3, 15,16,17,18,19, 20, 21, 22, 23, 24, 25]);
899
SynEdit.UnfoldAll; PopPushBaseName('(1st:: 0,1,F / 2nd:: x=2 skip c=1)');
900
TstFold (' fold pre-one col (pos): 0,1,F', 3, 0, 1, False, 1, [0,1,2,3, 19, 20, 21, 22, 23, 24, 25]);
901
TstFold (' fold 4th col (pos/skip): 2,1,T', 3, 2, 1, True, 1, [0,1,2,3, 19, 20, 21, 22, 23, 24, 25]);
902
// TstUnFold('UNfold 1st col (pos/no-sk): 0,1,F', 3, 0, 1, False, 1, [0,1,2,3, 13,14,15,16,17,18,19, 20, 21, 22, 23, 24, 25]);
905
{%region 1st:: 1,1,F}
908
{%region 1st:: -1,1,F}
911
{%region 1st:: -2,1,F}
914
{%endregion Text7 fold at indes, skip, ...}
931
procedure TTestFoldedView.TestFoldEdit;
933
procedure DoChar(x, y: integer; char: String);
935
SynEdit.CaretXY := Point(x,y);
936
SynEdit.CommandProcessor(ecChar, char, nil);
938
procedure DoNewLine(x, y: integer);
940
SynEdit.CaretXY := Point(x,y);
941
SynEdit.CommandProcessor(ecLineBreak, '', nil);
943
procedure DoBackspace(x, y: integer);
945
SynEdit.CaretXY := Point(x,y);
946
SynEdit.CommandProcessor(ecDeleteLastChar, '', nil);
949
procedure TestNodeAtPos(name: string; x, y: integer; ExpClassification: TFoldNodeClassification = fncHighlighter);
951
n: TSynTextFoldAVLNode;
953
n := TSynEditFoldedViewHack(FoldedView).FoldTree.FindFoldForLine(y, true);
954
AssertTrue(BaseTestName+' '+ name+ ' got node for line '+inttostr(y), n.IsInFold);
955
AssertTrue(BaseTestName+' '+ name+ ' got node Classification for line '+inttostr(y), n.Classification = ExpClassification);
956
AssertEquals(BaseTestName+' '+ name+ ' got node for src-line '+inttostr(y), y, n.SourceLine);
957
AssertEquals(BaseTestName+' '+ name+ ' got node for src-line '+inttostr(y)+' col='+inttostr(x), x, n.FoldColumn);
967
TstSetText('Simple: fold Prc', TestText);
969
TstFold('', 1, [0, 1]);
970
TestNodeAtPos('', 1, 2);
973
TestFoldedText('(ins char)', [0, 1]);
974
TestNodeAtPos('(ins char)', 2, 2);
977
TestFoldedText('(newline before)', [0, 1, 2]);
978
TestNodeAtPos('(newline before)', 2, 3);
981
TestFoldedText('(del newline)', [0, 1]);
982
TestNodeAtPos('(del newline)', 2, 2);
985
TestFoldedText('(del char)', [0, 1]);
986
TestNodeAtPos('(del char)', 1, 2);
989
TestFoldedText('(del to prev line)', [0]);
990
TestNodeAtPos('(del to prev line)', 13, 1);
992
DoNewLine(13,1); // newline, on same line
993
TestFoldedText('(newline on srcline)', [0, 1]);
994
TestNodeAtPos('(newline on srcline)', 1, 2);
997
TstSetText('Simple 2: edit del foldable line', TestText3);
998
TstFold('', 7, [0, 1, 2, 3, 4, 5, 6, 7, 10, 11]);
999
SetCaretAndSel(1,3, 1,4);
1000
SynEdit.CommandProcessor(ecDeleteChar, '', nil);
1001
TestFoldedText('fold after', [0, 1, 2, 3, 4, 5, 6, 9, 10]);
1008
TstSetText('Nested: fold Prc Beg ', TestText);
1010
for i := 0 to 63 do begin
1011
PushBaseName(inttostr(i));
1015
TstFold(n, 2, [0, 1, 2]); TestNodeAtPos(n, 1, 3);
1017
TstFold(n, 1, [0, 1]); TestNodeAtPos(n, 1, 2);
1020
//debugln(['############### ',n]);
1022
TestFoldedText(n, [0, 1]); TestNodeAtPos(n, 2, 2);
1023
if (i and 1) <> 0 then begin
1024
n := '(ins char) nested';
1025
//debugln(['############### ',n]);
1026
TstUnFoldAtCaret(n, 1,3, [0,1,2]); TestNodeAtPos(n, 1, 3);
1027
n := '(ins char) refold';
1028
TstFold(n, 1, [0, 1]); TestNodeAtPos(n, 2, 2); // re-folded
1031
n := '(newline before)';
1032
//debugln(['############### ',n]);
1034
TestFoldedText(n, [0, 1, 2]); TestNodeAtPos(n, 2, 3);
1035
if (i and 2) <> 0 then begin
1036
n := '(newline before) nested';
1037
//debugln(['############### ',n]);
1038
TstUnFoldAtCaret(n, 1,4, [0,1,2,3]); TestNodeAtPos(n, 1, 4);
1039
n := '(newline before) refold';
1040
TstFold(n, 2, [0, 1, 2]); TestNodeAtPos(n, 2, 3); // re-folded
1043
n := '(del newline)';
1044
//debugln(['############### ',n]);
1046
TestFoldedText(n, [0, 1]); TestNodeAtPos(n, 2, 2);
1047
if (i and 4) <> 0 then begin
1048
n := '(del newline) nested';
1049
//debugln(['############### ',n]);
1050
TstUnFoldAtCaret(n, 1,3, [0,1,2]); TestNodeAtPos(n, 1, 3);
1051
n := '(del newline) refold';
1052
TstFold(n, 1, [0, 1]); TestNodeAtPos(n, 2, 2); // re-folded
1056
//debugln(['############### ',n]);
1058
TestFoldedText(n, [0, 1]); TestNodeAtPos(n, 1, 2);
1059
if (i and 8) <> 0 then begin
1060
n := '(del char) nested';
1061
//debugln(['############### ',n]);
1062
TstUnFoldAtCaret(n, 1,3, [0,1,2]); TestNodeAtPos(n, 1, 3);
1063
n := '(del char) refold';
1064
TstFold(n, 1, [0, 1]); TestNodeAtPos(n, 1, 2); // re-folded
1067
n := '(del to prev line)';
1068
//debugln(['############### ',n]);
1070
TestFoldedText(n, [0]); TestNodeAtPos(n, 13, 1);
1071
if (i and 16) <> 0 then begin
1072
n := '(del to prev line) nested';
1073
TstUnFoldAtCaret(n, 1,2, [0,1]); TestNodeAtPos(n, 1, 2);
1074
n := '(del to prev line) refold';
1075
TstFold(n, 0, [0]); TestNodeAtPos(n, 13, 1); // re-folded
1078
n := '(newline on srcline)';
1079
DoNewLine(13,1); // newline, on same line
1080
TestFoldedText(n, [0, 1]); TestNodeAtPos(n, 1, 2);
1081
if (i and 32) <> 0 then begin
1082
n := '(del to prev line) nested';
1083
TstUnFoldAtCaret(n, 1,3, [0,1,2]); TestNodeAtPos(n, 1, 3);
1084
n := '(del to prev line) refold';
1085
TstFold(n, 1, [0,1]); TestNodeAtPos(n, 1, 2); // re-folded
1094
TstSetText('Nested, same line: fold Prc Beg', TestText6);
1096
for i := 0 to 255 do begin
1097
PushBaseName(inttostr(i));
1098
SetLines(TestText6);
1101
TstFold(n, 1, 1, [0, 1, 4,5,6]); TestNodeAtPos(n, 14, 2);
1103
TstFold(n, 1, 0, [0, 1]); TestNodeAtPos(n, 1, 2);
1106
//debugln(['############### ',n]);
1108
TestFoldedText(n, [0, 1]); TestNodeAtPos(n, 2, 2);
1109
if (i and 1) <> 0 then begin
1110
n := '(ins char) nested';
1111
//debugln(['############### ',n]);
1112
TstUnFoldAtCaret(n, 1,5, [0,1,4,5,6]); TestNodeAtPos(n, 15, 2);
1113
n := '(ins char) refold';
1114
TstFold(n, 1, 0, [0, 1]); TestNodeAtPos(n, 2, 2); // re-folded
1117
n := '(ins char middle)';
1118
//debugln(['############### ',n]);
1120
TestFoldedText(n, [0, 1]); TestNodeAtPos(n, 2, 2);
1121
if (i and 2) <> 0 then begin
1122
n := '(ins char middle) nested';
1123
//debugln(['############### ',n]);
1124
TstUnFoldAtCaret(n, 1,5, [0,1,4,5,6]); TestNodeAtPos(n, 16, 2);
1125
n := '(ins char middle) refold';
1126
TstFold(n, 1, 0, [0, 1]); TestNodeAtPos(n, 2, 2); // re-folded
1130
n := '(newline before)';
1131
//debugln(['############### ',n]);
1133
TestFoldedText(n, [0, 1, 2]); TestNodeAtPos(n, 2, 3);
1134
if (i and 4) <> 0 then begin
1135
n := '(newline before) nested';
1136
//debugln(['############### ',n]);
1137
TstUnFoldAtCaret(n, 1,6, [0,1,2, 5,6,7]); TestNodeAtPos(n, 16, 3);
1138
n := '(newline before) refold';
1139
TstFold(n, 2, 0, [0, 1, 2]); TestNodeAtPos(n, 2, 3); // re-folded
1142
n := '(del newline)';
1143
//debugln(['############### ',n]);
1145
TestFoldedText(n, [0, 1]); TestNodeAtPos(n, 2, 2);
1146
if (i and 8) <> 0 then begin
1147
n := '(del newline) nested';
1148
//debugln(['############### ',n]);
1149
TstUnFoldAtCaret(n, 1,5, [0,1, 4,5,6]); TestNodeAtPos(n, 16, 2);
1150
n := '(del newline) refold';
1151
TstFold(n, 1, 0, [0, 1]); TestNodeAtPos(n, 2, 2); // re-folded
1155
//debugln(['############### ',n]);
1157
TestFoldedText(n, [0, 1]); TestNodeAtPos(n, 1, 2);
1158
if (i and 16) <> 0 then begin
1159
n := '(del char) nested';
1160
//debugln(['############### ',n]);
1161
TstUnFoldAtCaret(n, 1,5, [0,1,4,5,6]); TestNodeAtPos(n, 15, 2);
1162
n := '(del char) refold';
1163
TstFold(n, 1, 0, [0, 1]); TestNodeAtPos(n, 1, 2); // re-folded
1166
n := '(del char middle)';
1167
//debugln(['############### ',n]);
1169
TestFoldedText(n, [0, 1]); TestNodeAtPos(n, 1, 2);
1170
if (i and 32) <> 0 then begin
1171
n := '(del char middle) nested';
1172
//debugln(['############### ',n]);
1173
TstUnFoldAtCaret(n, 1,5, [0,1,4,5,6]); TestNodeAtPos(n, 14, 2);
1174
n := '(del char middle) refold';
1175
TstFold(n, 1, 0, [0, 1]); TestNodeAtPos(n, 1, 2); // re-folded
1179
n := '(del to prev line)';
1180
//debugln(['############### ',n]);
1182
TestFoldedText(n, [0]); TestNodeAtPos(n, 13, 1);
1183
if (i and 64) <> 0 then begin
1184
n := '(del to prev line) nested';
1185
TstUnFoldAtCaret(n, 1,4, [0,3,4,5]); TestNodeAtPos(n, 26, 1);
1186
n := '(del to prev line) refold';
1187
TstFold(n, 0,1, [0]); TestNodeAtPos(n, 13, 1); // re-folded idx=1, prg is at 0
1190
n := '(newline on srcline)';
1191
DoNewLine(13,1); // newline, on same line
1192
TestFoldedText(n, [0, 1]); TestNodeAtPos(n, 1, 2);
1193
if (i and 128) <> 0 then begin
1194
n := '(del to prev line) nested';
1195
TstUnFoldAtCaret(n, 1,5, [0,1,4,5,6]); TestNodeAtPos(n, 14, 2);
1196
n := '(del to prev line) refold';
1197
TstFold(n, 1, 0, [0,1]); TestNodeAtPos(n, 1, 2); // re-folded
1205
TstSetText('Nested, same line, new line in middle:', TestText6);
1208
TstFold(n, 1, 1, [0, 1, 4,5,6]); TestNodeAtPos(n, 14, 2);
1210
TstFold(n, 1, 0, [0, 1]); TestNodeAtPos(n, 1, 2);
1212
//debugln(['############### ',n]);
1214
TestFoldedText(n, [0, 1, 2, 5,6,7]);
1215
TestNodeAtPos(n, 1, 3);
1218
TstSetText('Nested, same line, new line in middle: (2)', TestText6);
1221
TstFold(n, 1, 1, [0, 1, 4,5,6]); TestNodeAtPos(n, 14, 2);
1222
TstFold(n, 1, 0, [0, 1]); TestNodeAtPos(n, 1, 2);
1224
//debugln(['############### ',n]);
1226
TestFoldedText(n, [0, 1, 2, 5,6,7]);
1227
TestNodeAtPos(n, 2, 3);
1231
{%region simple, block edit}
1232
TstSetText('Simple: block edit', TestText);
1234
TstFold('', 1, [0, 1]);
1235
TestNodeAtPos('', 1, 2);
1237
SynEdit.TextBetweenPoints[point(1,2), point(1,2)] := ' ';
1238
TestFoldedText('(ins char)', [0, 1]);
1239
TestNodeAtPos('(ins char)', 2, 2);
1241
SynEdit.TextBetweenPoints[point(13,1), point(13,1)] := LineEnding;
1242
TestFoldedText('(newline before)', [0, 1, 2]);
1243
TestNodeAtPos('(newline before)', 2, 3);
1245
SynEdit.TextBetweenPoints[point(13,1), point(1,2)] := '';
1246
TestFoldedText('(del newline)', [0, 1]);
1247
TestNodeAtPos('(del newline)', 2, 2);
1249
SynEdit.TextBetweenPoints[point(1,2), point(2,2)] := '';
1250
TestFoldedText('(del char)', [0, 1]);
1251
TestNodeAtPos('(del char)', 1, 2);
1253
SynEdit.TextBetweenPoints[point(13,1), point(1,2)] := '';
1254
TestFoldedText('(del to prev line)', [0]);
1255
TestNodeAtPos('(del to prev line)', 13, 1);
1257
SynEdit.TextBetweenPoints[point(13,1), point(13,1)] := LineEnding;
1258
TestFoldedText('(newline on srcline)', [0, 1]);
1259
TestNodeAtPos('(newline on srcline)', 1, 2);
1262
SynEdit.TextBetweenPoints[point(1,3), point(1,3)] := LineEnding;
1263
TestFoldedText('(newline, 1st fold line)', [0, 1]);
1264
TestNodeAtPos('(newline 1st fold line)', 1, 2);
1266
SynEdit.TextBetweenPoints[point(1,3), point(1,4)] := '';
1267
TestFoldedText('(del newline, 1st fold line)', [0, 1]);
1268
TestNodeAtPos('(del newline 1st fold line)', 1, 2);
1273
{%region Nested block edit}
1274
TstSetText('Nested: block edit ', TestText);
1275
//SetLines(TestText);
1278
TstFold(n, 2, [0, 1, 2]); TestNodeAtPos(n, 1, 3);
1279
TstFold(n, 1, [0, 1]); TestNodeAtPos(n, 1, 2);
1280
//debugln(['############### ',n]);
1281
SynEdit.TextBetweenPoints[point(1,3), point(1,3)] := ' ';
1282
TestFoldedText(n, [0, 1]); TestNodeAtPos(n, 1, 2);
1283
TstUnFoldAtCaret(n, 1,3, [0,1,2]); TestNodeAtPos(n, 2, 3);
1285
n := '(repl char to newline)';
1286
TstFold(n, 1, [0, 1]); TestNodeAtPos(n, 1, 2);
1287
//debugln(['############### ',n]);
1288
SynEdit.TextBetweenPoints[point(1,3), point(2,3)] := LineEnding;
1289
TestFoldedText(n, [0, 1]); TestNodeAtPos(n, 1, 2);
1290
TstUnFoldAtCaret(n, 1,4, [0,1,2,3]); TestNodeAtPos(n, 1, 4);
1292
n := '(repl newline to char)';
1293
TstFold(n, 1, [0, 1]); TestNodeAtPos(n, 1, 2);
1294
//debugln(['############### ',n]);
1295
SynEdit.TextBetweenPoints[point(1,3), point(1,4)] := ' ';
1296
TestFoldedText(n, [0, 1]); TestNodeAtPos(n, 1, 2);
1297
TstUnFoldAtCaret(n, 1,3, [0,1,2]); TestNodeAtPos(n, 3, 3);
1300
TstFold(n, 1, [0, 1]); TestNodeAtPos(n, 1, 2);
1301
//debugln(['############### ',n]);
1302
SynEdit.TextBetweenPoints[point(1,3), point(3,3)] := '';
1303
TestFoldedText(n, [0, 1]); TestNodeAtPos(n, 1, 2);
1304
TstUnFoldAtCaret(n, 1,3, [0,1,2]); TestNodeAtPos(n, 1, 3);
1309
{%region simple, lines access}
1310
TstSetText('Simple: lines access', TestText);
1312
TstFold('', 1, [0, 1]);
1313
TestNodeAtPos('', 1, 2);
1315
SynEdit.Lines.Insert(1,'// foo');
1316
TestFoldedText('(insert before)', [0, 1, 2]);
1317
TestNodeAtPos('(insert before)', 1, 3);
1319
SynEdit.Lines.Delete(1);
1320
TestFoldedText('(del before)', [0, 1]);
1321
TestNodeAtPos('(del before)', 1, 2);
1323
SynEdit.Lines.Insert(2,'// foo');
1324
TestFoldedText('(insert inside)', [0, 1]);
1325
TestNodeAtPos('(insert inside)', 1, 2);
1327
SynEdit.Lines.Delete(2);
1328
TestFoldedText('(del inside)', [0, 1]);
1329
TestNodeAtPos('(del inside)', 1, 2);
1336
TstSetText('Simple HIDE', TestTextHide(3));
1338
TstFold('', 1, -1, 1, False, 0, [0, 4]);
1339
TestNodeAtPos('', 1, 2);
1342
TestFoldedText('(ins newline)', [0, 1, 5]);
1343
TestNodeAtPos('(ins newline)', 1, 3);
1345
SynEdit.Undo; // cannot use backspace, since caret would unfold
1346
TestFoldedText('(del newline)', [0, 4]);
1347
TestNodeAtPos('(del newline)', 1, 2);
1352
{%region hide, block edit}
1353
TstSetText('Simple HIDE: block edit', TestTextHide(3));
1355
// TODO /newline BEFORE
1356
TstFold('', 1, -1, 1, False, 0, [0, 4]);
1357
TestNodeAtPos('', 1, 2);
1359
SynEdit.TextBetweenPoints[point(13,1), point(13,1)] := LineEnding;
1360
TestFoldedText('(newline before)', [0, 1, 5]);
1361
TestNodeAtPos('(newline before)', 1, 3);
1363
SynEdit.TextBetweenPoints[point(13,1), point(1,2)] := '';
1364
TestFoldedText('(del newline before)', [0, 4]);
1365
TestNodeAtPos('(del newline before)', 1, 2);
1369
SynEdit.TextBetweenPoints[point(1,2), point(1,2)] := ' ';
1370
TestFoldedText('(ins char)', [0, 4]);
1371
TestNodeAtPos('(ins char)', 2, 2);
1373
debugln(['############### ins newline']);
1374
SynEdit.TextBetweenPoints[point(1,2), point(2,2)] := LineEnding;
1375
TestFoldedText('(ins newline)', [0, 1, 5]);
1376
TestNodeAtPos('(ins newline)', 1, 3);
1378
debugln(['############### del newline']);
1379
SynEdit.TextBetweenPoints[point(1,2), point(1,3)] := ' ';
1380
TestFoldedText('(del newline)', [0, 4]);
1381
TestNodeAtPos('(del newline)', 3, 2);
1383
debugln(['############### del char']);
1384
SynEdit.TextBetweenPoints[point(1,2), point(3,2)] := ' ';
1385
TestFoldedText('(del char)', [0, 4]);
1386
TestNodeAtPos('(del char)', 2, 2);
1388
debugln(['############### ins newline (again)']);
1389
SynEdit.TextBetweenPoints[point(1,2), point(2,2)] := LineEnding;
1390
TestFoldedText('(ins newline)', [0, 1, 5]);
1391
TestNodeAtPos('(ins newline)', 1, 3);
1393
debugln(['############### del TWO newline']);
1394
SynEdit.TextBetweenPoints[point(1,2), point(1,4)] := '';
1395
TestFoldedText('(del newline)', [0, 3]);
1396
TestNodeAtPos('(del newline)', 1, 2);
1401
{%region lines access}
1402
TstSetText('Simple HIDE: lines access', TestTextHide(3));
1404
TstFold('', 1, -1, 1, False, 0, [0, 4]);
1405
TestNodeAtPos('', 1, 2);
1407
SynEdit.Lines.Insert(1,'var a: integer;');
1408
TestFoldedText('(ins newline before)', [0, 1, 5]);
1409
TestNodeAtPos('(ins newline before)', 1, 3);
1411
SynEdit.Lines.Delete(1);
1412
TestFoldedText('(del newline before)', [0, 4]);
1413
TestNodeAtPos('(del newline before)', 1, 2);
1415
SynEdit.Lines.Insert(2,'// foo bar');
1416
TestFoldedText('(ins newline inside)', [0, 5]);
1417
TestNodeAtPos('(ins newline inside)', 1, 2);
1419
SynEdit.Lines.Delete(2);
1420
TestFoldedText('(del newline inside)', [0, 4]);
1421
TestNodeAtPos('(del newline inside)', 1, 2);
1427
TstSetText('TestText10 remove one entire fold', TestText10);
1428
TstFold('f1', 7, -1, 1, False, 1, [0, 1, 2, 3, 4, 5, 6, 7, 13, 14, 15]);
1429
TstFold('f2', 3, -1, 1, False, 1, [0, 1, 2, 3, 6, 7, 13, 14, 15]);
1430
TestNodeAtPos('n1', 15, 4);
1431
TestNodeAtPos('n2', 15, 8);
1433
SetCaretAndSel(1, 4, 1, 8);
1434
SynEdit.CutToClipboard;
1436
TstFold('f2', 3, -1, 1, False, 1, [0, 1, 2, 3, 9, 10, 11]);
1437
TestNodeAtPos('n3', 15, 4);
1443
// 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33
1444
TstSetText('TestTextBug21473', TestTextBug21473);
1445
TstFold('FooB', 25, -1, 1, False, 1, [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25, 28,29,30,31,32,33]);
1446
TstFold('FooA', 21, -1, 1, False, 1, [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21, 24,25, 28,29,30,31,32,33]);
1447
TstFold('Foo ', 19, -1, 1, False, 1, [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19, 31,32,33]);
1449
TestNodeAtPos('n1', 1, 20);
1451
s := SynEdit.TextBetweenPoints[point(1,7), point(1,10)];
1452
SynEdit.TextBetweenPoints[point(1,6), point(1,9)] := '';
1454
TestFoldedText('Cut', [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16, 28,29,30]);
1455
TestNodeAtPos('n1 Cut', 1, 17);
1457
SynEdit.TextBetweenPoints[point(1,7), point(1,7)] := s;
1459
TestFoldedText('Restore', [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19, 31,32,33]);
1460
TestNodeAtPos('n1 Restore', 1, 20);
1463
//debugln('*********AFTER UNDO'); FoldedView.debug;
1465
TestFoldedText('Undone', [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16, 28,29,30]);
1466
TestNodeAtPos('n1 Undone', 1, 17);
1468
//SetCaretAndSel(1, 4, 1, 8);
1469
//SynEdit.CutToClipboard;
590
1477
procedure TTestFoldedView.TestFoldStateFromText;
591
procedure TstSetText(AName: String; AText: TStringArray);
599
1479
procedure TstFoldState(AName, AFoldDesc: String; AExpectedLines: Array of Integer);
698
1580
//TestCompareString('FoldDesc (txt / ext)', ' TA004 T12025',
699
1581
// FoldedView.GetFoldDescription(0,1,-1,-1, True, True)
1587
// No crash,if folded selection
1589
SetLines(TestTextPlain);
1590
SetCaretAndSel(1,5, 2,6);
1591
FoldedView.FoldAtTextIndex(4, 0, 1, False, 0);
1592
AssertEquals(FoldedView.Count, 8);
1594
FoldedView.GetFoldDescription(0, 0, -1, -1, True, False);
1595
FoldedView.GetFoldDescription(0, 0, -1, -1, False, False);
1596
FoldedView.GetFoldDescription(0, 0, -1, -1, True, True);
1597
FoldedView.GetFoldDescription(0, 0, -1, -1, False, True);
1599
// compare fold desc with/without selection-fold
1601
SetLines(TestTextPlain);
1602
FoldedView.FoldAtTextIndex(0);
1603
FoldedView.FoldAtTextIndex(7);
1604
AssertEquals(FoldedView.Count, 6);
1606
a1 := FoldedView.GetFoldDescription(0, 0, -1, -1, True, False);
1607
a2 := FoldedView.GetFoldDescription(0, 0, -1, -1, False, False);
1608
a3 := FoldedView.GetFoldDescription(0, 0, -1, -1, True, True);
1609
a4 := FoldedView.GetFoldDescription(0, 0, -1, -1, False, True);
1611
SetCaretAndSel(1,5, 2,6);
1612
FoldedView.FoldAtTextIndex(4, 0, 1, False, 0);
1613
AssertEquals(FoldedView.Count, 4);
1615
TestCompareString('1', a1, FoldedView.GetFoldDescription(0, 0, -1, -1, True, False));
1616
TestCompareString('2', a2, FoldedView.GetFoldDescription(0, 0, -1, -1, False, False));
1617
// a3 := FoldedView.GetFoldDescription(0, 0, -1, -1, True, True);
1618
// a4 := FoldedView.GetFoldDescription(0, 0, -1, -1, False, True);
1622
procedure TTestFoldedView.TestFoldProvider;
1623
procedure DoTestOpenCounts(AName: string; AType: Integer; AExp: Array of Integer);
1627
AName := AName + ' (type=' + IntToStr(AType)+') ';
1628
for i := low(AExp) to high(AExp) do
1629
DebugLn([BaseTestName+AName+ ' line=' + IntToStr(i)+ ' exp=', AExp[i],' Got=', FoldedView.FoldProvider.FoldOpenCount(i, AType)]);
1630
for i := low(AExp) to high(AExp) do
1631
AssertEquals(BaseTestName+AName+ ' line=' + IntToStr(i),
1632
AExp[i], FoldedView.FoldProvider.FoldOpenCount(i, AType));
1638
// TSynEditFoldProvider.FoldOpenCount(ALineIdx: Integer; AType: Integer = 0): Integer;
1641
TstSetText('TestText1', TestText);
1642
EnableFolds([cfbtBeginEnd..cfbtNone]);
1644
DoTestOpenCounts('', 0, [1, 1, 1, 0, 0]); // all (fold conf)
1645
DoTestOpenCounts('', 1, [1, 1, 1, 0, 0]); // pas
1646
//DoTestOpenCounts('', 4, [1, 1, 1, 0, 0]); // pas (incl unfolded)
1647
DoTestOpenCounts('', 2, [0, 0, 0, 0, 0]); // %region
1648
DoTestOpenCounts('', 3, [0, 0, 0, 0, 0]); // $if
1650
TstSetText('TestText1 (2)', TestText);
1651
EnableFolds([cfbtTopBeginEnd]);
1653
DoTestOpenCounts('', 0, [0, 0, 1, 0, 0]); // all (fold conf)
1654
DoTestOpenCounts('', 1, [0, 0, 1, 0, 0]); // pas
1655
//DoTestOpenCounts('', 4, [1, 1, 1, 0, 0]); // pas (incl unfolded)
1656
DoTestOpenCounts('', 2, [0, 0, 0, 0, 0]); // %region
1657
DoTestOpenCounts('', 3, [0, 0, 0, 0, 0]); // $if
1659
TstSetText('TestText1 (3)', TestText);
1660
EnableFolds([cfbtProcedure, cfbtBeginEnd]);
1662
DoTestOpenCounts('', 0, [0, 1, 0, 0, 0]); // all (fold conf)
1663
DoTestOpenCounts('', 1, [0, 1, 0, 0, 0]); // pas
1664
//DoTestOpenCounts('', 4, [1, 1, 1, 0, 0]); // pas (incl unfolded)
1665
DoTestOpenCounts('', 2, [0, 0, 0, 0, 0]); // %region
1666
DoTestOpenCounts('', 3, [0, 0, 0, 0, 0]); // $if
1670
TstSetText('TestText2', TestText2);
1671
EnableFolds([cfbtBeginEnd..cfbtNone]);
1673
// p PP B - B B ~ -B ~ - - ~
1674
DoTestOpenCounts('', 0, [1, 2, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0]);
1675
DoTestOpenCounts('', 1, [1, 2, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0]);
1676
//DoTestOpenCounts('', 4, [1, 2, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0]);
1677
DoTestOpenCounts('', 2, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
1678
DoTestOpenCounts('', 3, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
1680
TstSetText('TestText2 (2)', TestText2);
1681
EnableFolds([cfbtBeginEnd..cfbtNone]-[cfbtProgram, cfbtRegion]);
1682
// p PP B - B B ~ -B ~ - - ~
1683
DoTestOpenCounts('', 0, [0, 2, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0]);
1684
DoTestOpenCounts('', 1, [0, 2, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0]);
1685
//DoTestOpenCounts('', 4, [1, 2, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0]);
1686
DoTestOpenCounts('', 2, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
1687
DoTestOpenCounts('', 3, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
1691
TstSetText('TestText3', TestText3);
1692
EnableFolds([cfbtBeginEnd..cfbtNone], [cfbtSlashComment]);
1693
// if else // one-line-comment
1694
// p $ P - B %B ~ --B~ - - /
1695
DoTestOpenCounts('', 0, [1, 1, 1, 0, 1, 2, 0, 1, 0, 0, 0, 1]);
1696
DoTestOpenCounts('', 1, [1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1]);
1697
//DoTestOpenCounts('', 4, [1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1]);
1698
DoTestOpenCounts('', 2, [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]); // %region
1699
DoTestOpenCounts('', 3, [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); // %if
1701
TstSetText('TestText3 (2)', TestText3);
1702
EnableFolds([cfbtBeginEnd..cfbtNone]-[cfbtProgram, cfbtRegion], [cfbtSlashComment]);
1703
// p $ P - B %B ~ --B~ - - /
1704
DoTestOpenCounts('', 0, [0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1]);
1705
DoTestOpenCounts('', 1, [0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1]);
1706
//DoTestOpenCounts('', 4, [1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1]);
1707
DoTestOpenCounts('', 2, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); // %region
1708
DoTestOpenCounts('', 3, [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); // %if
1710
TstSetText('TestText3 (3)', TestText3);
1711
EnableFolds([cfbtBeginEnd..cfbtNone]-[cfbtProgram, cfbtIfDef], []);
1712
// p $ P - B %B ~ --B~ - - /
1713
DoTestOpenCounts('', 0, [0, 0, 1, 0, 1, 2, 0, 1, 0, 0, 0, 0]);
1714
DoTestOpenCounts('', 1, [0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0]);
1715
//DoTestOpenCounts('', 4, [1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1]);
1716
DoTestOpenCounts('', 2, [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]); // %region
1717
DoTestOpenCounts('', 3, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); // %if
1721
for i := 0 to 2 do begin // pos of $IFDEF does not matter
1722
TstSetText('TestTextPasHl-'+IntToStr(i)+'', TestTextPasHl(i));
1723
EnableFolds([cfbtBeginEnd..cfbtNone], [cfbtSlashComment]);
1724
// if $E // one-line-comment
1726
DoTestOpenCounts('', 0, [1, 1, 3, 0, 0, 0, 1]);
1727
DoTestOpenCounts('', 1, [1, 1, 2, 0, 0, 0, 1]);
1728
//DoTestOpenCounts('', 4, [1, 1, 2, 0, 0, 0, 1]);
1729
DoTestOpenCounts('', 2, [0, 0, 0, 0, 0, 0, 0]); // %region
1730
DoTestOpenCounts('', 3, [0, 0, 1, 0, 0, 0, 0]); // %if
1732
TstSetText('TestTextPasHl-'+IntToStr(i)+'', TestTextPasHl(i));
1733
EnableFolds([cfbtBeginEnd..cfbtNone]-[cfbtBeginEnd], [cfbtSlashComment]);
1734
// if $E // one-line-comment
1736
DoTestOpenCounts('', 0, [1, 1, 2, 0, 0, 0, 1]);
1737
DoTestOpenCounts('', 1, [1, 1, 1, 0, 0, 0, 1]);
1738
//DoTestOpenCounts('', 4, [1, 1, 1, 0, 0, 0, 1]);
1739
DoTestOpenCounts('', 2, [0, 0, 0, 0, 0, 0, 0]); // %region
1740
DoTestOpenCounts('', 3, [0, 0, 1, 0, 0, 0, 0]); // %if
1742
TstSetText('TestTextPasHl-'+IntToStr(i)+'', TestTextPasHl(i));
1743
EnableFolds([cfbtBeginEnd..cfbtNone]-[cfbtIfDef], [cfbtSlashComment]);
1744
// if $E // one-line-comment
1746
DoTestOpenCounts('', 0, [1, 1, 2, 0, 0, 0, 1]);
1747
DoTestOpenCounts('', 1, [1, 1, 2, 0, 0, 0, 1]);
1748
//DoTestOpenCounts('', 4, [1, 1, 2, 0, 0, 0, 1]);
1749
DoTestOpenCounts('', 2, [0, 0, 0, 0, 0, 0, 0]); // %region
1750
DoTestOpenCounts('', 3, [0, 0, 0, 0, 0, 0, 0]); // %if
1755
TstSetText('TestText4', TestText4);
1756
EnableFolds([cfbtBeginEnd..cfbtNone], [cfbtSlashComment]);
1758
DoTestOpenCounts('', 0, [3, 1, 0, 1, 0, 1]);
1759
DoTestOpenCounts('', 1, [3, 1, 0, 1, 0, 1]);
1760
//DoTestOpenCounts('', 4, [3, 1, 0, 1, 0, 1]);
1761
DoTestOpenCounts('', 2, [0, 0, 0, 0, 0, 0]);
1762
DoTestOpenCounts('', 3, [0, 0, 0, 0, 0, 0]);
1766
TstSetText('TestText8', TestText8);
1767
EnableFolds([cfbtBeginEnd..cfbtNone], [cfbtSlashComment]);
1768
// p P B % $ B % $ B ~ % ~ B ~ $ ~ - ~ -
1769
DoTestOpenCounts('', 0, [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0]);
1770
DoTestOpenCounts('', 1, [1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]);
1771
//DoTestOpenCounts('', 4, [1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]);
1772
DoTestOpenCounts('', 2, [0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]);
1773
DoTestOpenCounts('', 3, [0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]);
1777
procedure TTestFoldedView.TestNestedFoldsList;
1778
Procedure CheckNode(nd: TSynFoldNodeInfo; ALine: TLineIdx; AColumn: integer;
1779
LogXStart, LogXEnd, FoldLvlStart, FoldLvlEnd, NestLvlStart, NestLvlEnd: Integer;
1780
FoldType: integer; FoldTypeCompatible: integer; FoldGroup: Integer;
1781
FoldAction: TSynFoldActions);
1783
AssertEquals(Format('%s (%d/%d) LineIndex', [BaseTestName, ALine, AColumn]), ALine, nd.LineIndex);
1784
AssertEquals(Format('%s (%d/%d) NodeIndex', [BaseTestName, ALine, AColumn]), AColumn, nd.NodeIndex);
1785
if not(sfaInvalid in nd.FoldAction) then begin
1786
AssertEquals(Format('%s (%d/%d) LogXStart', [BaseTestName, ALine, AColumn]), LogXStart, nd.LogXStart);
1787
AssertEquals(Format('%s (%d/%d) LogXEnd', [BaseTestName, ALine, AColumn]), LogXEnd, nd.LogXEnd);
1788
if FoldLvlStart >= 0 then
1789
AssertEquals(Format('%s (%d/%d) FoldLvlStart', [BaseTestName, ALine, AColumn]), FoldLvlStart, nd.FoldLvlStart);
1790
if FoldLvlEnd >= 0 then
1791
AssertEquals(Format('%s (%d/%d) FoldLvlEnd', [BaseTestName, ALine, AColumn]), FoldLvlEnd, nd.FoldLvlEnd);
1792
AssertEquals(Format('%s (%d/%d) NestLvlStart', [BaseTestName, ALine, AColumn]), NestLvlStart, nd.NestLvlStart);
1793
AssertEquals(Format('%s (%d/%d) NestLvlEnd', [BaseTestName, ALine, AColumn]), NestLvlEnd, nd.NestLvlEnd);
1794
AssertEquals(Format('%s (%d/%d) FoldType', [BaseTestName, ALine, AColumn]), PtrUInt(FoldType), PtrUInt(nd.FoldType));
1795
AssertEquals(Format('%s (%d/%d) FoldTypeCompatible', [BaseTestName, ALine, AColumn]), PtrUInt(FoldTypeCompatible), PtrUInt(nd.FoldTypeCompatible));
1796
AssertEquals(Format('%s (%d/%d) FoldGroup:', [BaseTestName, ALine, AColumn]), FoldGroup, nd.FoldGroup);
1798
AssertEquals(Format('%s (%d/%d) FoldAction', [BaseTestName, ALine, AColumn]), FoldActionsToString(FoldAction), FoldActionsToString(nd.FoldAction));
1801
TheList: TLazSynEditNestedFoldsList;
1803
// L= *(\d+).*?(\d+).*?(\d+).*?(\d+).*?(\d+).*?(\d+).*?(\d+).*?(\d+).*?(\d+).*?(\d+).*?(\d+).*?A=(.*)
1804
// CheckNode(TheList.HLNode[2], $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12);
1809
TstSetText('TestText1', TestText);
1810
TheList := FoldedView.FoldProvider.NestedFoldsList;
1811
EnableFolds([cfbtBeginEnd..cfbtNone]);
1813
PushBaseName('All Enabled - group 0');
1814
TheList.ResetFilter;
1816
TheList.FoldGroup := 0;
1817
TheList.FoldFlags := [];
1818
AssertEquals(BaseTestName + 'Cnt', 3, TheList.Count);
1819
CheckNode(TheList.HLNode[2], 2, 0, 0, 5, 2, 3, 2, 3, 1, 0, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
1820
CheckNode(TheList.HLNode[1], 1, 0, 0, 9, 1, 2, 1, 2, 3, 3, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
1821
CheckNode(TheList.HLNode[0], 0, 0, 0, 7, 0, 1, 0, 1, 10, 10, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
1824
PopPushBaseName('All Enabled - group 1');
1825
TheList.ResetFilter;
1827
TheList.FoldGroup := 1;
1828
TheList.FoldFlags := [];
1829
AssertEquals(BaseTestName + 'Cnt', 3, TheList.Count);
1830
CheckNode(TheList.HLNode[2], 2, 0, 0, 5, 2, 3, 2, 3, 1, 0, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
1831
CheckNode(TheList.HLNode[1], 1, 0, 0, 9, 1, 2, 1, 2, 3, 3, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
1832
CheckNode(TheList.HLNode[0], 0, 0, 0, 7, 0, 1, 0, 1, 10, 10, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
1835
PopPushBaseName('All Enabled - group 2');
1836
TheList.ResetFilter;
1838
TheList.FoldGroup := 2;
1839
TheList.FoldFlags := [];
1840
AssertEquals(BaseTestName + 'Cnt', 0, TheList.Count);
1843
PopPushBaseName('All Enabled - group 0 - NoCurrentLine');
1844
TheList.ResetFilter;
1846
TheList.FoldGroup := 0;
1847
TheList.FoldFlags := [];
1848
TheList.IncludeOpeningOnLine := False;
1849
AssertEquals(BaseTestName + 'Cnt', 2, TheList.Count);
1850
CheckNode(TheList.HLNode[1], 1, 0, 0, 9, 1, 2, 1, 2, 3, 3, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
1851
CheckNode(TheList.HLNode[0], 0, 0, 0, 7, 0, 1, 0, 1, 10, 10, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
1854
PopPushBaseName('All Enabled - group 0 - NoCurrentLine - line 3');
1855
TheList.ResetFilter;
1857
TheList.FoldGroup := 0;
1858
TheList.FoldFlags := [];
1859
TheList.IncludeOpeningOnLine := False;
1860
AssertEquals(BaseTestName + 'Cnt', 3, TheList.Count);
1861
CheckNode(TheList.HLNode[2], 2, 0, 0, 5, 2, 3, 2, 3, 1, 0, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
1862
CheckNode(TheList.HLNode[1], 1, 0, 0, 9, 1, 2, 1, 2, 3, 3, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
1863
CheckNode(TheList.HLNode[0], 0, 0, 0, 7, 0, 1, 0, 1, 10, 10, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
1866
EnableFolds([cfbtTopBeginEnd]);
1867
PopPushBaseName('cfbtTopBeginEnd Enabled - group 0');
1868
TheList.ResetFilter;
1870
TheList.FoldGroup := 0;
1871
TheList.FoldFlags := [];
1872
AssertEquals(BaseTestName + 'Cnt', 1, TheList.Count);
1873
CheckNode(TheList.HLNode[0], 2, 0, 0, 5, 0, 1, 2, 3, 1, 0, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
1876
EnableFolds([cfbtTopBeginEnd]);
1877
PopPushBaseName('cfbtTopBeginEnd Enabled - group 1');
1878
TheList.ResetFilter;
1880
TheList.FoldGroup := 1;
1881
TheList.FoldFlags := [];
1882
AssertEquals(BaseTestName + 'Cnt', 1, TheList.Count);
1883
CheckNode(TheList.HLNode[0], 2, 0, 0, 5, 0, 1, 2, 3, 1, 0, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
1886
EnableFolds([cfbtTopBeginEnd]);
1887
PopPushBaseName('cfbtTopBeginEnd Enabled - group 0 - NoCurrentLine');
1888
TheList.ResetFilter;
1890
TheList.FoldGroup := 0;
1891
TheList.FoldFlags := [];
1892
TheList.IncludeOpeningOnLine := False;
1893
AssertEquals(BaseTestName + 'Cnt', 0, TheList.Count);
1896
EnableFolds([cfbtTopBeginEnd]);
1897
PopPushBaseName('cfbtTopBeginEnd Enabled - group 0 - NoCurrentLine line 3');
1898
TheList.ResetFilter;
1900
TheList.FoldGroup := 0;
1901
TheList.FoldFlags := [];
1902
TheList.IncludeOpeningOnLine := False;
1903
AssertEquals(BaseTestName + 'Cnt', 1, TheList.Count);
1904
CheckNode(TheList.HLNode[0], 2, 0, 0, 5, 0, 1, 2, 3, 1, 0, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
1908
PopPushBaseName('cfbtTopBeginEnd Enabled - group 0 - sfbIncludeDisabled');
1909
TheList.ResetFilter;
1911
TheList.FoldGroup := 0;
1912
TheList.FoldFlags := [sfbIncludeDisabled];
1913
AssertEquals(BaseTestName + 'Cnt', 3, TheList.Count);
1914
CheckNode(TheList.HLNode[2], 2, 0, 0, 5, 0, 1, 2, 3, 1, 0, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
1915
CheckNode(TheList.HLNode[1], 1, 0, 0, 9, -1,-1, 1, 2, 3, 3, 1, [sfaOpen,sfaMarkup]);
1916
CheckNode(TheList.HLNode[0], 0, 0, 0, 7, -1,-1, 0, 1, 10, 10, 1, [sfaOpen,sfaMarkup]);
1919
EnableFolds([cfbtTopBeginEnd]);
1920
PopPushBaseName('cfbtTopBeginEnd Enabled - group 1 - sfbIncludeDisabled');
1921
TheList.ResetFilter;
1923
TheList.FoldGroup := 1;
1924
TheList.FoldFlags := [sfbIncludeDisabled];
1925
AssertEquals(BaseTestName + 'Cnt', 3, TheList.Count);
1926
CheckNode(TheList.HLNode[2], 2, 0, 0, 5, 0, 1, 2, 3, 1, 0, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
1927
CheckNode(TheList.HLNode[1], 1, 0, 0, 9, -1,-1, 1, 2, 3, 3, 1, [sfaOpen,sfaMarkup]);
1928
CheckNode(TheList.HLNode[0], 0, 0, 0, 7, -1,-1, 0, 1, 10, 10, 1, [sfaOpen,sfaMarkup]);
1931
EnableFolds([cfbtTopBeginEnd]);
1932
PopPushBaseName('cfbtTopBeginEnd Enabled - group 2 - sfbIncludeDisabled');
1933
TheList.ResetFilter;
1935
TheList.FoldGroup := 2;
1936
TheList.FoldFlags := [sfbIncludeDisabled];
1937
AssertEquals(BaseTestName + 'Cnt', 0, TheList.Count);
1940
EnableFolds([cfbtTopBeginEnd]);
1941
PopPushBaseName('cfbtTopBeginEnd Enabled - group 0 - NoCurrentLine - sfbIncludeDisabled');
1942
TheList.ResetFilter;
1944
TheList.FoldGroup := 0;
1945
TheList.FoldFlags := [sfbIncludeDisabled];
1946
TheList.IncludeOpeningOnLine := False;
1947
AssertEquals(BaseTestName + 'Cnt', 2, TheList.Count);
1948
CheckNode(TheList.HLNode[1], 1, 0, 0, 9, -1,-1, 1, 2, 3, 3, 1, [sfaOpen,sfaMarkup]);
1949
CheckNode(TheList.HLNode[0], 0, 0, 0, 7, -1,-1, 0, 1, 10, 10, 1, [sfaOpen,sfaMarkup]);
1952
EnableFolds([cfbtTopBeginEnd]);
1953
PopPushBaseName('cfbtTopBeginEnd Enabled - group 0 - NoCurrentLine line 3 - sfbIncludeDisabled');
1954
TheList.ResetFilter;
1956
TheList.FoldGroup := 0;
1957
TheList.FoldFlags := [sfbIncludeDisabled];
1958
TheList.IncludeOpeningOnLine := False;
1959
AssertEquals(BaseTestName + 'Cnt', 3, TheList.Count);
1960
CheckNode(TheList.HLNode[2], 2, 0, 0, 5, 0, 1, 2, 3, 1, 0, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
1961
CheckNode(TheList.HLNode[1], 1, 0, 0, 9, -1,-1, 1, 2, 3, 3, 1, [sfaOpen,sfaMarkup]);
1962
CheckNode(TheList.HLNode[0], 0, 0, 0, 7, -1,-1, 0, 1, 10, 10, 1, [sfaOpen,sfaMarkup]);
1965
// TODO line, currently ignores the opening "begin" on current line
1967
PopPushBaseName('None Enabled - group 0 - sfbIncludeDisabled - line 3');
1968
TheList.ResetFilter;
1970
TheList.FoldGroup := 0;
1971
TheList.FoldFlags := [sfbIncludeDisabled];
1972
AssertEquals(BaseTestName + 'Cnt', 3, TheList.Count);
1973
CheckNode(TheList.HLNode[2], 2, 0, 0, 5, -1,-1, 2, 3, 1, 0, 1, [sfaOpen,sfaMarkup]);
1974
CheckNode(TheList.HLNode[1], 1, 0, 0, 9, -1,-1, 1, 2, 3, 3, 1, [sfaOpen,sfaMarkup]);
1975
CheckNode(TheList.HLNode[0], 0, 0, 0, 7, -1,-1, 0, 1, 10, 10, 1, [sfaOpen,sfaMarkup]);
1979
{%endregion TestText1}
1983
TstSetText('TestText2', TestText2);
1984
TheList := FoldedView.FoldProvider.NestedFoldsList;
1985
EnableFolds([cfbtBeginEnd..cfbtNone]);
1987
PushBaseName('All Enabled - group 0 - line 1');
1988
TheList.ResetFilter;
1990
TheList.FoldGroup := 0;
1991
TheList.FoldFlags := [];
1992
AssertEquals(BaseTestName + 'Cnt', 3, TheList.Count);
1993
CheckNode(TheList.HLNode[2], 1, 1, 13, 22, 2, 3, 2, 3, 3, 3, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
1994
CheckNode(TheList.HLNode[1], 1, 0, 0, 9, 1, 2, 1, 2, 3, 3, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
1995
CheckNode(TheList.HLNode[0], 0, 0, 0, 7, 0, 1, 0, 1, 10, 10, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
1998
PopPushBaseName('All Enabled - group 0 - line 1 - no current');
1999
TheList.ResetFilter;
2001
TheList.FoldGroup := 0;
2002
TheList.FoldFlags := [];
2003
TheList.IncludeOpeningOnLine := False;
2004
AssertEquals(BaseTestName + 'Cnt', 1, TheList.Count);
2005
CheckNode(TheList.HLNode[0], 0, 0, 0, 7, 0, 1, 0, 1, 10, 10, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
2008
PopPushBaseName('All Enabled - group 0 - line 3');
2009
TheList.ResetFilter;
2011
TheList.FoldGroup := 0;
2012
TheList.FoldFlags := [];
2013
AssertEquals(BaseTestName + 'Cnt', 4, TheList.Count);
2014
CheckNode(TheList.HLNode[3], 2, 0, 2, 7, 3, 4, 3, 4, 1, 0, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
2015
CheckNode(TheList.HLNode[2], 1, 1, 13, 22, 2, 3, 2, 3, 3, 3, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
2016
CheckNode(TheList.HLNode[1], 1, 0, 0, 9, 1, 2, 1, 2, 3, 3, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
2017
CheckNode(TheList.HLNode[0], 0, 0, 0, 7, 0, 1, 0, 1, 10, 10, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
2020
PopPushBaseName('All Enabled - group 0 - line 4');
2021
TheList.ResetFilter;
2023
TheList.FoldGroup := 0;
2024
TheList.FoldFlags := [];
2025
AssertEquals(BaseTestName + 'Cnt', 3, TheList.Count);
2026
CheckNode(TheList.HLNode[2], 4, 0, 23, 28, 2, 3, 2, 3, 1, 0, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
2027
CheckNode(TheList.HLNode[1], 1, 0, 0, 9, 1, 2, 1, 2, 3, 3, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
2028
CheckNode(TheList.HLNode[0], 0, 0, 0, 7, 0, 1, 0, 1, 10, 10, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
2031
PopPushBaseName('All Enabled - group 0 - line 4 - NO IncludeOpeningOnLine');
2032
TheList.ResetFilter;
2034
TheList.FoldGroup := 0;
2035
TheList.FoldFlags := [];
2036
TheList.IncludeOpeningOnLine := False;
2037
AssertEquals(BaseTestName + 'Cnt', 2, TheList.Count);
2038
CheckNode(TheList.HLNode[1], 1, 0, 0, 9, 1, 2, 1, 2, 3, 3, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
2039
CheckNode(TheList.HLNode[0], 0, 0, 0, 7, 0, 1, 0, 1, 10, 10, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
2042
PopPushBaseName('All Enabled - group 0 - line 5');
2043
TheList.ResetFilter;
2045
TheList.FoldGroup := 0;
2046
TheList.FoldFlags := [];
2047
AssertEquals(BaseTestName + 'Cnt', 4, TheList.Count);
2048
CheckNode(TheList.HLNode[3], 5, 0, 12, 17, 3, 4, 3, 4, 0, 0, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
2049
CheckNode(TheList.HLNode[2], 4, 0, 23, 28, 2, 3, 2, 3, 1, 0, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
2050
CheckNode(TheList.HLNode[1], 1, 0, 0, 9, 1, 2, 1, 2, 3, 3, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
2051
CheckNode(TheList.HLNode[0], 0, 0, 0, 7, 0, 1, 0, 1, 10, 10, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
2054
{%endregion TestText2}
2059
TstSetText('TestText3', TestText3);
2060
TheList := FoldedView.FoldProvider.NestedFoldsList;
2061
EnableFolds([cfbtBeginEnd..cfbtNone]);
2063
PushBaseName('All Enabled - group 0 - line 3');
2064
TheList.ResetFilter;
2066
TheList.FoldGroup := 0;
2067
TheList.FoldFlags := [];
2068
AssertEquals(BaseTestName + 'Cnt', 3, TheList.Count);
2069
CheckNode(TheList.HLNode[2], 2, 0, 0, 9, 1, 2, 1, 2, 3, 3, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
2070
CheckNode(TheList.HLNode[1], 1, 0, 2, 7, 0, 1, 0, 1, 18, 18, 3, [sfaOpen,sfaFold,sfaFoldFold]);
2071
CheckNode(TheList.HLNode[0], 0, 0, 0, 7, 0, 1, 0, 1, 10, 10, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
2074
PushBaseName('All Enabled - group 1 - line 3');
2075
TheList.ResetFilter;
2077
TheList.FoldGroup := 1;
2078
TheList.FoldFlags := [];
2079
AssertEquals(BaseTestName + 'Cnt', 2, TheList.Count);
2080
CheckNode(TheList.HLNode[1], 2, 0, 0, 9, 1, 2, 1, 2, 3, 3, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
2081
CheckNode(TheList.HLNode[0], 0, 0, 0, 7, 0, 1, 0, 1, 10, 10, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
2084
PushBaseName('All Enabled - group 3 - line 3');
2085
TheList.ResetFilter;
2087
TheList.FoldGroup := 3;
2088
TheList.FoldFlags := [];
2089
AssertEquals(BaseTestName + 'Cnt', 1, TheList.Count);
2090
CheckNode(TheList.HLNode[0], 1, 0, 2, 7, 0, 1, 0, 1, 18, 18, 3, [sfaOpen,sfaFold,sfaFoldFold]);
2093
PopPushBaseName('All Enabled - group 0 - line 3');
2094
TheList.ResetFilter;
2096
TheList.FoldGroup := 0;
2097
TheList.FoldFlags := [];
2098
AssertEquals(BaseTestName + 'Cnt', 3, TheList.Count);
2099
CheckNode(TheList.HLNode[2], 4, 0, 0, 5, 2, 3, 2, 3, 1, 0, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
2100
CheckNode(TheList.HLNode[1], 2, 0, 0, 9, 1, 2, 1, 2, 3, 3, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
2101
CheckNode(TheList.HLNode[0], 0, 0, 0, 7, 0, 1, 0, 1, 10, 10, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
2104
{%endregion TestText2}
2107
TstSetText('TestText9', TestText9);
2108
TheList := FoldedView.FoldProvider.NestedFoldsList;
2109
EnableFolds([cfbtBeginEnd..cfbtNone]);
2111
PushBaseName('All Enabled - group 0 - line 3');
2112
TheList.ResetFilter;
2114
TheList.FoldGroup := 0;
2115
TheList.FoldFlags := [];
2116
AssertEquals(BaseTestName + 'Cnt', 3, TheList.Count);
2117
CheckNode(TheList.HLNode[2], 2, 0, 0, 5, 2, 3, 2, 3, 1, 0, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
2118
CheckNode(TheList.HLNode[1], 1, 0, 0, 9, 1, 2, 1, 2, 3, 3, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);
2119
CheckNode(TheList.HLNode[0], 0, 0, 0, 7, 0, 1, 0, 1, 10, 10, 1, [sfaOpen,sfaMarkup,sfaFold,sfaFoldFold]);