mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-05 23:38:21 +02:00
SynEdit search: Fix searching multi-line text. Found text could have longer lines (Pattern expected line-end), if start matched.
git-svn-id: trunk@39845 -
This commit is contained in:
parent
81894596dd
commit
ade191f786
@ -612,13 +612,12 @@ var
|
|||||||
//DebugLn(['MultiLinePatternFits Forward: line too short']);
|
//DebugLn(['MultiLinePatternFits Forward: line too short']);
|
||||||
exit; // line too short
|
exit; // line too short
|
||||||
end;
|
end;
|
||||||
if (LineEndPos=length(Pat)) and (CompareEndPos>length(CurLineStr)) then
|
If (CompareEndPos <> length(CurLineStr)) and
|
||||||
begin
|
(LineEndPos+1+Length(LineEnding) <= length(Pat)) and
|
||||||
//DebugLn(['MultiLinePatternFits Forward: line too long']);
|
CompareMem(@Pat[LineEndPos+1], PChar(LineEnding), length(LineEnding))
|
||||||
exit; // line too long
|
then
|
||||||
end;
|
exit; // Not last line, and not same length
|
||||||
if (LineStartPos<=length(Pat))
|
if (not CompareContent(PChar(CurLineStr),@Pat[LineStartPos],
|
||||||
and (not CompareContent(PChar(CurLineStr),@Pat[LineStartPos],
|
|
||||||
CompareEndPos))
|
CompareEndPos))
|
||||||
then begin
|
then begin
|
||||||
//DebugLn(['MultiLinePatternFits Forward: line mismatches']);
|
//DebugLn(['MultiLinePatternFits Forward: line mismatches']);
|
||||||
|
@ -26,6 +26,7 @@ type
|
|||||||
procedure TestSearchSimpleUtf8;
|
procedure TestSearchSimpleUtf8;
|
||||||
procedure TestSearchSimpleRegEx;
|
procedure TestSearchSimpleRegEx;
|
||||||
procedure FindMatchingBracket;
|
procedure FindMatchingBracket;
|
||||||
|
procedure TestSearchMultiLine; // not regex
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -251,6 +252,36 @@ begin
|
|||||||
hl.Free;
|
hl.Free;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TTestSynSearch.TestSearchMultiLine;
|
||||||
|
begin
|
||||||
|
ReCreateEdit;
|
||||||
|
SetLines(['', // 1
|
||||||
|
'a',
|
||||||
|
'',
|
||||||
|
'b',
|
||||||
|
'', // 5
|
||||||
|
'a',
|
||||||
|
'x',
|
||||||
|
'b',
|
||||||
|
'',
|
||||||
|
'a', // 10
|
||||||
|
'x2',
|
||||||
|
'b',
|
||||||
|
'']);
|
||||||
|
|
||||||
|
fTSearch := TSynEditSearch.Create;
|
||||||
|
fTSearch.Sensitive := False;
|
||||||
|
fTSearch.Whole := False;
|
||||||
|
fTSearch.Backwards := False;
|
||||||
|
fTSearch.RegularExpressions := False;
|
||||||
|
fTSearch.RegExprMultiLine := False;
|
||||||
|
fTSearch.Replacement := '';
|
||||||
|
|
||||||
|
TestFindNext('3 lines middle empty', 'a'+LineEnding+LineEnding+'b', 1,1, 1,9, true, 1,2, 2,4);
|
||||||
|
TestFindNext('3 lines middle empty - no match', 'a'+LineEnding+LineEnding+'b', 1,5, 1,9, False, 1,2, 2,4);
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
//more ftsearch:
|
//more ftsearch:
|
||||||
//function FindAll(const NewText: string): integer;
|
//function FindAll(const NewText: string): integer;
|
||||||
//function FindFirstUTF8(const NewText: string): Integer;
|
//function FindFirstUTF8(const NewText: string): Integer;
|
||||||
|
Loading…
Reference in New Issue
Block a user