View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0002503 | JEDI VCL | 00 JVCL Components | public | 2005-01-15 12:34 | 2005-08-10 08:13 |
Reporter | Simes | Assigned To | obones | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Product Version | 3.00 BETA 2 | ||||
Target Version | Fixed in Version | 3.10 | |||
Summary | 0002503: TJvFindReplace dialog doesn't replace all occurences on ReplaceAll | ||||
Description | Run the code below. When the replace dialog appears, click the Replace All button. The first occurence of "main" isn't replaced. | ||||
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('unit main frm;'); Memo1.Lines.Add('main this main that maintain main'); Memo1.Lines.Add('a main b'); 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. | ||||
|
More info: DoOnReplace first calls DoOnFind. DoOnFind sets the selection of the edit control to the first match, then when DoOnReplace calls ReplaceAll, this starts its search from the end of the current select block. So the first match is missed. |
|
Suggested changes: procedure TJvFindReplace.DoOnReplace(Sender: TObject); begin if frReplaceAll in TFindDialog(Sender).Options then begin SetFindText(FReplaceDialog.FindText); SetReplaceText(FReplaceDialog.ReplaceText); ReplaceAll(FFindText, FReplaceText); if Assigned(FOnReplace) then FOnReplace(Self); end else begin if FEditControl.SelLength < 1 then DoOnFind(Sender); if FEditControl.SelLength < 1 then Exit; ReplaceOne(Sender); if Assigned(FOnReplace) then FOnReplace(Self); DoOnFind(Sender); end; end; |
|
See 2515 - it has a modified version of this component. |
Date Modified | Username | Field | Change |
---|---|---|---|
2005-01-15 12:34 | Simes | New Issue | |
2005-01-15 12:48 | Simes | Note Added: 0006140 | |
2005-01-15 13:04 | Simes | Note Added: 0006142 | |
2005-01-15 13:27 | Simes | Note Edited: 0006142 | |
2005-01-15 13:29 | Simes | Note Edited: 0006142 | |
2005-01-16 00:57 | Simes | Note Edited: 0006142 | |
2005-01-16 13:04 | Simes | Note Added: 0006156 | |
2005-01-17 03:13 | obones | Relationship added | related to 0002515 |
2005-08-10 07:50 | 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 |