TurboPack / SynEdit

SynEdit is a syntax highlighting edit control, not based on the Windows common controls.
216 stars 72 forks source link

Search / replace text sometimes work not well #250

Open jacek-mulawka opened 4 months ago

jacek-mulawka commented 4 months ago

Hey,

sometimes the functionality 'search / replace' text work not well. Maybe I do something wrong. I checked the SearchReplaceDemo and my own projects. For example I try to replace 'aa' with 'w' (or 'ccc'): 1

aa = aa bb

2

and the result is: 1

w w = aa bb

2

here 'ap_faktury_it' with 'ap_faktury_out': 1

SELECT ap_faktury_it.indeks_wyrobu, ap_faktury_it.nazwa_wyrobu FROM ap_faktury_it

2

and the result is: 1

aap_faktury_outtury_out.indeks_wyrobu, ap_faktury_out.nazwa_wyrobu FROM ap_faktury_out

2

I am not sure why it for some strings work good and for others not. Maybe it depend if a sub-string occurs several times in the same line.

I have a hint. If in the file plgSearchHighlighter.pas change the lines (around line number 95)

    ACanvas.FillRect(Rct);
    ACanvas.TextRect(Rct, Pt.X, Pt.Y, SearchResultText);

to

    ACanvas.FillRect(Rct);
    ACanvas.Rectangle( Rct.Left - margin_c, Rct.Top - margin_c, Rct.Right + margin_c, Rct.Bottom + margin_c ); // const margin_c : integer = 3;
    ACanvas.Font := Editor.Font;
    ACanvas.TextRect(Rct, Pt.X, Pt.Y, SearchResultText);

the text inside the highlight rectangle may better fit to the editor's font (e.g. if someone change the editor's font size) and the rectangle may have a border.

Greetings!