Forum > Editor

match automatic highlight on NON matching text?

(1/2) > >>

Чебурашка:
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.

Martin_fr:
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:
Btw, and without wanting to interfere with your teams guidelines, but have you considered: AnObject instead of Aobject ?

Чебурашка:

--- Quote from: Martin_fr 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 ?

--- End quote ---

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.

Чебурашка:

--- Quote from: Martin_fr on April 23, 2024, 09:42:58 am ---Maybe there should be options for:
- toggling "highlight current selection"
- disable during search and replace

--- End quote ---

This is what I hoped...


--- Quote from: Martin_fr on April 23, 2024, 09:42:58 am ---There are some other ways of renaming stuff.

--- End quote ---

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.

Navigation

[0] Message Index

[#] Next page

Go to full version