Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0002504 [JEDI VCL] 00 JVCL Components minor always 2005-01-15 12:38 2005-08-10 08:13
Reporter Simes View Status public  
Assigned To obones
Priority normal Resolution fixed  
Status resolved   Product Version 3.00 BETA 2
Summary 0002504: TJvFindReplace dialog doesn't replace with whole-word-only option
Description Run the code below. When the replace dialog appears, select whole-word-only option, then click the Replace All button. No occurences of "main" are found.
Additional Information unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, JvComponent, JvFindReplace;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Button1: TButton;
    JvFindReplace1: TJvFindReplace;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
  public
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormShow(Sender: TObject);
begin
  Button1.Caption := 'Reset';
  Button2.Caption := 'Test';
  Button1Click(self);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Memo1.Clear;
  Memo1.Lines.Add('a main main something');
  Memo1.Lines.Add('main this main that maintain main');
  Memo1.Lines.Add('another main');
  Memo1.CaretPos := Point(0, 0);
  Memo1.SetFocus;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  JvFindReplace1.Options := [frDown];
  JvFindReplace1.EditControl := Memo1;
  JvFindReplace1.FindText := 'main';
  JvFindReplace1.ReplaceText := 'abcd';
  JvFindReplace1.Replace;
end;


end.

Tags No tags attached.
Attached Files

- Relationships
related to 0002515resolvedobones Modified TJvFindReplace source to correct issues 2503, 2504, 2513 

-  Notes
(0006143)
Simes (reporter)
2005-01-15 13:11

also fails on Find aswell as replace.
(0006144)
Simes (reporter)
2005-01-15 13:15

Suggested changes maked with //SDA

function FindInText(const Text, Search: string; FromPos, ToPos: Integer; Fast: Boolean): TFoundText;
var
  Found: Integer;
  S: string;
begin
  Result.StartAt := -1; // assume failure
  if Fast then
    Found := BoyerMoore(PChar(AnsiUpperCase(Search)), PChar(AnsiUpperCase(Copy(Text, FromPos + 1, ToPos))))
  else
    Found := Pos(AnsiUpperCase(Search), AnsiUpperCase(Copy(Text, FromPos + 1, ToPos)));
  if Found > 0 then begin
    Result.StartAt := Found + FromPos; // sda
    if FromPos > 0 then // sda
      dec(Result.StartAt); // sda
    Result.EndAt := Length(Search);
    S := Copy(Text, Result.StartAt - 1, Result.EndAt + 2);
    // check for extremes...
    // is find string the same as the whole string?
    if Length(Search) = Length(Text) then begin
      Result.isWhole := True;
      S := Text;
    end else begin
      // check for match at beginning or end of string
      if Result.StartAt - 1 <= 0 then//sda
        S := Copy(' ' + S, 1, Result.EndAt + 2);
      if Result.StartAt - 1 + Result.EndAt + 2 > Length(Text) then
        S := Copy(S + ' ', Length(Text) - Result.EndAt - 1, Result.EndAt + 2);
      Result.isWhole := IsValidWholeWord(S);
      S := Copy(S, 2, Length(S) - 2);
    end;
    Result.isSameCase := (AnsiCompareStr(trim(Search), trim(S)) = 0);
    if FromPos = 0 then// sda
     dec(Result.StartAt); // sda
  end;
end;
(0006155)
Simes (reporter)
2005-01-16 13:04

See 2515 - it has a modified version of this component.

- Issue History
Date Modified Username Field Change
2005-01-15 12:38 Simes New Issue
2005-01-15 13:11 Simes Note Added: 0006143
2005-01-15 13:15 Simes Note Added: 0006144
2005-01-16 13:04 Simes Note Added: 0006155
2005-01-17 03:14 obones Relationship added related to 0002515
2005-08-10 07:51 obones Status new => confirmed
2005-08-10 08:13 obones Status confirmed => resolved
2005-08-10 08:13 obones Resolution open => fixed
2005-08-10 08:13 obones Assigned To => obones


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker