Adventures renaming files in VSC land

Let's be real. A seasoned developer never uses names like unit1, because it does not helps on a project to quickly locate functions and so forth.
So the first thing I do is to rename the file sets (pas, dfm and html). Back when I was using delphi, it was an easy task. But in VSC I have ran into multiple problems. I read another thread with similar issues. I found a workaround but I guess the developers either need to publish a way of renaming (or I just have not found it), of actually add the functionality so we can "refactor" without problem.
One simple suggestion I can make is to ask the name we want when creating a new form instead of going with the standard name.

In my case, I managed to have a consistent problem in a sample project I am attaching here, so read on. I copied the project folder to my mac and the problem is still there, so I say is something reproducible.

Form designer problem:
Am not sure if it fails with simple units (ie. the ones that don't have a dfm and html ), but the first problem I ran is when creating a new form. VSC creates and saves the set (set=pas, dfm and html). I want the files named similarly, so I used the file view, right click, rename them. Even when editing the dpr and the pas and dfm to have the correct references in code, the form designer doesn't open when clicking CTRL-F12 I even went to erase the hidden .vscode and TMSweb folders, then reopen the project and form designer doesn't work with that unit. In my sample code, the password unit was originally named unit5 I think. I renamed the set to password.pas, .dfm and .html and corrected all code references. I don't see what is wrong there, but form designer does not open with that file.

My workaround is to close VSC, erase .vscode and TMSweb folders, copy a basic set of three files (pas, dfm, html) rename them, and edit them using Geany or Notepad++ so their internal code is correct and points to the right files and declarations. The file set "alerts" was created in that way. Then I copied the set to my project folder, then open VSC, right clicked on alerts.pas-> Add to project. This is a workaround that works. VSC is the one that added it to the .dpr project.

VSC auto renaming my files:
Another problem I ran into is that I renamed unit2 set to userunit. Form designer didn't work like described above, so I renamed it back to unit2. But VSC kept renaming the .pas file to unit21.pas and refused to put the name I want. In the end I just deleted all the set and tried until I found my workaround above.

I guess the problem resides inside the .dproj file, but have not had the time to crack the problem or to analyze how it behaves when adding, renaming, deleting files. Within VSC I found not a way to edit it as text.

The sample project attached is an empty skeleton of my multiform application. Am sure it will carry the problem the same way it did into my local computers. The affected files are commented. Each form has just a couple of random components here and there, but for password.pas the form designer does not open, so I left it empty with the purpose of sharing here to give the developers a clue. (alerts.pas was created with geany as mentioned and the FD works with it).
Am sure the code references are correct for password.pas and its set, but if am wrong am listening.

In the end, I would like to know if there is some information for a procedure on how to correctly rename within VSC, without recurring to other tools. And perhaps someone can provide a clue on how to edit the .dproj (which I think is the problem) to correctly include the files with names I want. When opening the dproj with geany it is an xml and it even has some embarcadero and delphi references. the password set is referenced there, but even so the form designer does not open. Would be very nice to be able to crack this issue.

    <DCCReference Include="Password.pas">
      <Form>FormPassword</Form>
      <FormType>dfm</FormType>
      <DesignClass>TWebForm</DesignClass>
    </DCCReference>

JD
unitRenameTest.zip (14.6 KB)

Thanks for such detailed message, so let's go step by step in order to find where the problem is and fix it.
First Step: To rename a set (.pas, .dfm, .html), simply rename the .pas file, and VSC will rename .dfm and .html accordingly, and will change all references in .dpr and .dproj automatically. Does this doesn't work for you?

Thanks!

renaming

Jose, I tried on the Mac and it sure worked, corrected all references and did everything. My previous procedure was to rename the form in code, save, rename the dfm and that is where problem started.
In the project with problems I renamed the password.pas file to something else and it indeed corrected everything.
Say no more. problem solved, thanks.