Recent

Author Topic: match automatic highlight on NON matching text?  (Read 1042 times)

Чебурашка

  • Hero Member
  • *****
  • Posts: 579
  • СЛАВА УКРАЇНІ! / Slava Ukraïni!
match automatic highlight on NON matching text?
« on: April 23, 2024, 09:17:08 am »
Hello,
I am doing a code refactoring in order to comply with a new coding standard I decided with my team.

One of my modifications is this: substitute a parameter of a procedure whose name was "o" (was a o: TObject) with "Aobject". Please nobody laugh on "o" (facepalm).

Now my problem is this: I did a replace on local file "o" to "Aobject" with case sensitive and whole word options checked and it works. But since I must be sure of each swap I need to give confirmation of each replace. The problem is that when a match is found, it is automatically selected for being replaced, but along with it, there is also a plenty of NON matches partially highlighted. Why is lazarus showing those invalid ones? What is the sense? Can I prevent this from happening?

The lazarus I am telling in this post is the one written below for Linux (2.0.10)

ADDENDUM: I know that the feature comes from the automatic highlighting of the selected text, but since the selected text in turn comes from the search itself, I believe it would be more smart to link it to the options asked by the user, that include case sensitivity and whole word in this case.


See attached picture.
« Last Edit: April 23, 2024, 09:36:19 am by Чебурашка »
FPC 3.2.0/Lazarus 2.0.10+dfsg-4+b2 on Debian 11.5
FPC 3.2.2/Lazarus 2.2.0 on Windows 10 Pro 21H2

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10008
  • Debugger - SynEdit - and more
    • wiki
Re: match automatic highlight on NON matching text?
« Reply #1 on: April 23, 2024, 09:42:58 am »
That would be "Highlight current word".

If you normally edit the text, then whatever word is at the text-cursor (caret) is highlighted everywhere in the text (after a 1 second wait time).

You can find the settings under Tools > Options > Editor > Color: "Highlight current word"
Simple "uncheck" the colors (foreground/background/...) and it stops.
Also under Tools > Options > Editor > Markup and Matches: you can set the time, and minimum length for full words. But if you select text, it is always the selection.

Maybe there should be options for:
- toggling "highlight current selection"
- disable during search and replace




There are some other ways of renaming stuff.

Refactor "rename identifier"
Source editor, context menu > Refactoring   OR menu: Source > Refactoring.

Syncro edit: https://wiki.freepascal.org/New_IDE_features_since#Syncron-Edit
Select the entire procedure, then click the icon in the gutter or use ctrl-j.
Any word that appears more than once, will be in a "box". Editing it in one place will edit all others.


Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10008
  • Debugger - SynEdit - and more
    • wiki
Re: match automatic highlight on NON matching text?
« Reply #2 on: April 23, 2024, 09:44:52 am »
Btw, and without wanting to interfere with your teams guidelines, but have you considered: AnObject instead of Aobject ?

Чебурашка

  • Hero Member
  • *****
  • Posts: 579
  • СЛАВА УКРАЇНІ! / Slava Ukraïni!
Re: match automatic highlight on NON matching text?
« Reply #3 on: April 23, 2024, 10:04:24 am »
Btw, and without wanting to interfere with your teams guidelines, but have you considered: AnObject instead of Aobject ?

Simply we set the convention that all parameters class methods must start with A<something>, regardless of what is after. Then for classes, the fields with start with F<something> while when exposed they will be just <Something>. We extended the A rule also to all procs.

Of course AnObject is a more elegant English, but then one has to think about when the AnObject has to be tranformed into ASome/Many/Multiple/SeveralObjects or AnObjectsList in case input becomes a list. I prefer a simpler Aobject/Aobjects, taste.

FPC 3.2.0/Lazarus 2.0.10+dfsg-4+b2 on Debian 11.5
FPC 3.2.2/Lazarus 2.2.0 on Windows 10 Pro 21H2

Чебурашка

  • Hero Member
  • *****
  • Posts: 579
  • СЛАВА УКРАЇНІ! / Slava Ukraïni!
Re: match automatic highlight on NON matching text?
« Reply #4 on: April 23, 2024, 10:07:45 am »
Maybe there should be options for:
- toggling "highlight current selection"
- disable during search and replace

This is what I hoped...

There are some other ways of renaming stuff.

I know that there are some refactoring tools, but I am not confident in them. I my programming life I had bad experiences with blind renaming, so I never use them. Maybe because when I started doing software I used very poor tools.
FPC 3.2.0/Lazarus 2.0.10+dfsg-4+b2 on Debian 11.5
FPC 3.2.2/Lazarus 2.2.0 on Windows 10 Pro 21H2

WooBean

  • Full Member
  • ***
  • Posts: 243
Re: match automatic highlight on NON matching text?
« Reply #5 on: April 23, 2024, 11:15:00 am »
Btw, and without wanting to interfere with your teams guidelines, but have you considered: AnObject instead of Aobject ?

Just paralel observation from core Lazarus source code -  there are 22 "AIdentifier" and 31 "AnIdentifier" usages.
We can survive it, anyway.
Platforms: Win7/64, Linux Mint Ulyssa/64

cdbc

  • Hero Member
  • *****
  • Posts: 1250
    • http://www.cdbc.dk
Re: match automatic highlight on NON matching text?
« Reply #6 on: April 23, 2024, 11:30:08 am »
Hi
Correct english would be: AnObject & AnIdentifier. Elegant too...
/AObject/ really hurts my eyes.
Just my 2 cents
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

Чебурашка

  • Hero Member
  • *****
  • Posts: 579
  • СЛАВА УКРАЇНІ! / Slava Ukraïni!
Re: match automatic highlight on NON matching text?
« Reply #7 on: April 23, 2024, 11:35:14 am »
Hi
Correct english would be: AnObject & AnIdentifier. Elegant too...
/AObject/ really hurts my eyes.
Just my 2 cents
Regards Benny

Despite I love the beauty of English, I try to focus on efficiency/simplicity because I believe I am not writing prose or poetry, just software.
Moreover it is just pascal/delphi IDEs favouring this kind of parameters naming, other languages I worked with don't do the same (C,C++,Java,C#,Ruby,Perl,PHP,VB)
« Last Edit: April 23, 2024, 11:38:42 am by Чебурашка »
FPC 3.2.0/Lazarus 2.0.10+dfsg-4+b2 on Debian 11.5
FPC 3.2.2/Lazarus 2.2.0 on Windows 10 Pro 21H2

 

TinyPortal © 2005-2018