Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2025-05

Feature Request: Don't auto-add units

6 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Timothy Groves

It frustrates me that Lazarus always adds new units to the uses clause of the project source.? Especially if you don't want them there.? Which I almost never do.? Especially considering that it adds them named as 'unit1', et cetera, and as soon as you change the name of the unit - which you *will* do - it throws an error.

Can we get a way to disable this 'feature'?

Also:? Is there a better place to put a feature request?

Reply by email

Mattias Gaertner
to Timothy Groves
Timothy Groves wrote 7 lines
It frustrates me that Lazarus always adds new units to the uses clause of the project source.? Especially if you don't want them there.? Which I almost never do.? Especially considering that it adds them named as 'unit1', et cetera, and as soon as you change the name of the unit - which you *will* do - it throws an error. Can we get a way to disable this 'feature'?

Disable

Project / Project Options/ Miscellaneous / Main Unit has uses section ...

Mattias

Reply by email

Juha Manninen
to Timothy Groves: It frustrates me that Lazarus always adds new units to the uses clause of the project…

On Wed, May 7, 2025 at 8:37?PM Timothy Groves via lazarus <

Show quoted text 5 lines
wrote: Especially considering that it adds them named as 'unit1', et cetera, and as soon as you change the name of the unit - which you *will* do - it throws an error.

How to reproduce the error?
Here the name is changed in the project source file and in other units using it.
The first time I get a dialog which tells the unit is used elsewhere and offers to update the uses sections. I always select "Change all" or similar. (I don't have the dialog open now)
If the error is caused by that dialog, IMO it should be removed completely. Renamed units must be updated in uses sections *always*. I don't see any reason to ask about it.

Juha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20250510/36ee5e3d/attachment.htm>

Reply by email

Michael Van Canneyt
to Juha Manninen
Juha Manninen wrote 17 lines
On Wed, May 7, 2025 at 8:37?PM Timothy Groves via lazarus < > wrote: > Especially considering that it adds them named as > 'unit1', et cetera, and as soon as you change the name of the unit - > which you *will* do - it throws an error. How to reproduce the error? Here the name is changed in the project source file and in other units using it. The first time I get a dialog which tells the unit is used elsewhere and offers to update the uses sections. I always select "Change all" or similar. (I don't have the dialog open now) If the error is caused by that dialog, IMO it should be removed completely. Renamed units must be updated in uses sections *always*. I don't see any reason to ask about it.

There is:

I often rename a unit to make a duplicate to experiment with changes. In that case, the original unit must not be removed and all units must keep the old name in their uses clause. So the question is useful.

Beside this use case, I think it is good practice to point out to the user the consequences of an action. He may change his mind.

VS code 'automagically' does a lot of things and gets it wrong a little too often to my taste. Lazarus has a relatively good track record in this regard, so let us not spoil that.

If you really want to get rid of the question, make it a setting somewhere.

Michael.

Reply by email

Sven Barth
to Timothy Groves: It frustrates me that Lazarus always adds new units to the uses clause of the project…
Timothy Groves wrote 5 lines
It frustrates me that Lazarus always adds new units to the uses clause of the project source.? Especially if you don't want them there.? Which I almost never do.? Especially considering that it adds them named as 'unit1', et cetera, and as soon as you change the name of the unit - which you *will* do - it throws an error.

For me Lazarus adjusts the unit name when you store the newly added unit or even save it with a different name later on.

Regards,
Sven

Reply by email