TCustomRichMemo.Search():boolean fails under Linux
Original Reporter info from Mantis: dbannon @davidbannon
-
Reporter name: David
Original Reporter info from Mantis: dbannon @davidbannon
- Reporter name: David
Description:
About line #1080 in Richmemo.pas you find Search(...):boolean implemented. (Don't confuse with Search(...):integer.).
This function does not set the Result at the start and always (under Linux) returns true. Even when the GTK system has set ATextStart to -1.
Steps to reproduce:
var
Start, len : longint;
begin
RichMemo1.Clear;
RichMemo1.Append('This is some text to search');
if Richmemo1.Search('xxxx', 1, 25, [], Start, Len) then
showmessage('found ' + inttostr(Start) + ' ' + inttostr(Len))
else showmessage('Failed to find');
end;
Tells us it Found xxxx at -1 !
Additional information:
Easily fixed. Has been tested under Win10 and Linux GTK2. Add two lines to make the function look like this -
begin
Result := false; // Add this line !!!!!!!!
if not HandleAllocated then HandleNeeded;
if HandleAllocated then begin
so.len:=Len;
so.start:=Start;
so.options:=SearchOpt;
if not TWSCustomRichMemoClass(WidgetSetClass).isSearchEx then begin
ATextStart:=TWSCustomRichMemoClass(WidgetSetClass).Search(Self, ANiddle, so);
// not recommended. The text found coulbe longer than Niddle
// depending on the language and search options (to be done)
// mostly for Arabi and Hebrew languages
ATextLength:=UTF8Length(ANiddle);
if ATextStart >= 0 then Result := true; // and Add this line !!!!!!!
end else begin
Result:=TWSCustomRichMemoClass(WidgetSetClass).SearchEx(Self, ANiddle, so, ATextStart, ATextLength);
end;
end else
Result:=false;
end;
Mantis conversion info:
- Mantis ID: 32297
- OS: Ubuntu mate, 17.04
- Platform: Linux
- Version: 1.8RC4
- Monitored by: » @davidbannon (David)