View Issue Details

IDProjectCategoryView StatusLast Update
0032297Lazarus CCRPackagespublic2019-11-07 11:35
ReporterDavidAssigned ToDmitry Boyarintsev 
PrioritynormalSeverityminorReproducibilityalways
Status assignedResolutionopen 
PlatformLinuxOSUbuntu mate, 17.04OS Version
Summary0032297: TCustomRichMemo.Search():boolean fails under Linux
DescriptionAbout line 0001080 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 Reproducevar
    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 InformationEasily 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;
TagsNo tags attached.
WidgetsetGTK 2
Attached Files
  • 32297.patch (481 bytes)
    --- richmemo.pas-ref	2019-11-07 20:36:20.621131335 +1100
    +++ richmemo.pas	2019-11-07 20:42:53.509677431 +1100
    @@ -1086,6 +1086,7 @@
           // 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;
         end else begin
           Result:=TWSCustomRichMemoClass(WidgetSetClass).SearchEx(Self, ANiddle, so, ATextStart, ATextLength);
         end;
    
    32297.patch (481 bytes)

Activities

David

2017-09-16 10:31

reporter   ~0102867

For the record, does not solve the separate problem on Cocoa. But does no harm....

David

2019-07-25 13:38

reporter   ~0117390

Last edited: 2019-11-07 11:35

View 2 revisions

Hmm, someone seems to have partly followed up on this but only added one of the two necessary extra lines.

still need
.....
    ATextLength:=UTF8Length(ANiddle);
    if ATextStart >= 0 then Result := true; // and Add this line !!!!!!!
end else begin
.....

Now, the function always returns false on linux !


I am happy to provide a patch but its such a trivial edit .....

Davo

David

2019-11-07 11:34

reporter   ~0119131

OK, here is a patch. Needs to be applied down in the Richmemo directory.

Davo

32297.patch (481 bytes)
--- richmemo.pas-ref	2019-11-07 20:36:20.621131335 +1100
+++ richmemo.pas	2019-11-07 20:42:53.509677431 +1100
@@ -1086,6 +1086,7 @@
       // 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;
     end else begin
       Result:=TWSCustomRichMemoClass(WidgetSetClass).SearchEx(Self, ANiddle, so, ATextStart, ATextLength);
     end;
32297.patch (481 bytes)

Issue History

Date Modified Username Field Change
2017-08-19 13:25 David New Issue
2017-08-19 15:07 Bart Broersma Project Packages => Lazarus CCR
2017-09-16 10:31 David Note Added: 0102867
2019-01-29 19:56 Dmitry Boyarintsev Status new => assigned
2019-01-29 19:56 Dmitry Boyarintsev Assigned To => Dmitry Boyarintsev
2019-07-25 13:38 David Note Added: 0117390
2019-11-07 11:34 David File Added: 32297.patch
2019-11-07 11:34 David Note Added: 0119131
2019-11-07 11:35 David Note Edited: 0117390 View Revisions