Author Topic: File created with "New item from Template" not added to the current project  (Read 2433 times)

patrickkox

  • Senior Community Member
  • Posts: 136
  • Hero Points: 6
  • Debian GNU/Linux user
I thought that with version 24 a new file added with File -> New Item from Template... was automatically added to the current active project (or that there was a checkbox that you could set to do this), but with version 25.0.0.9 This seems to be not working or missing?

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6826
  • Hero Points: 526
Hmm...it seems like that check box should still be there.

As a work around, you can right click on the Project file in the Project Tool window and choose Add>Item from Template to Project...

dunkers

  • Senior Community Member
  • Posts: 774
  • Hero Points: 36
Just popped in to report this one too. I need to be quicker off the mark...

patrickkox

  • Senior Community Member
  • Posts: 136
  • Hero Points: 6
  • Debian GNU/Linux user
Hmm...it seems like that check box should still be there.

As a work around, you can right click on the Project file in the Project Tool window and choose Add>Item from Template to Project...
I was looking for this option, but didn't see it. Seems that I was looking by clicking on the "Source Files" folder icon in the Project Tool Window, but I should be right-clicking on the Project Name (Folder Icon) instead of the one I did.
This shows the dialog box with the checkbox to add the file to the project. I would expect that since this does the same thing the window should be the same.

dunkers

  • Senior Community Member
  • Posts: 774
  • Hero Points: 36
Seems to be a problem with the workaround.

I create a .c and .h via the templates. The .c shows up in the editor but the .h doesn't. So, from the projects toolbar I right click the folder, add files, select both files and add them. They are both in the project now, but when I open the .h it is set to plain text mode instead of C/C++ mode.

I think the same thing happens if they are added from the project properties menu, which is strange because adding a tree at the start worked as expected. I wonder if the auto-mode detection is broken.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6826
  • Hero Points: 526
I tried using the "C++ Basic Class" template. For me the .h file gets added to the project followed by a Slick-C stack so the .cpp file doesn't get added. I'm not seeing a problem with the file mode.

There's a problem with project_add_file(). You probably got a Slick-C stack which prevented more than 1 file being added to the project.

From what you describe, it sounds like neither file was added to the project. Maybe I would have to try the same template as you.

I've added a hot fix for the Add to Project controls not showing up. A hot fix has also been added for project_add_file .

dunkers

  • Senior Community Member
  • Posts: 774
  • Hero Points: 36
Doesn't happen with the supplied C++ 'base' class. I don't get a stack trace either. Interestingly, the .h gets loaded in the editor whilst the .cpp doesn't - the opposite to my c/h files.

I've attached my template files.

dunkers

  • Senior Community Member
  • Posts: 774
  • Hero Points: 36
Adding the .c manually from the project properties menu, then the .h ditto, results in the .h being seen as C/C++. So presumably it's the adding them together that causes it.

Edit: There was another possibility - that it's the right click which is the problem. So I just ran through every combination and it all worked perfectly! But... I used the same filename (because that's the file I actually want to edit) and there's a slim chance that SE remembers the file and mode because of that. I'll try with different filenames when I get time...
« Last Edit: October 29, 2020, 11:38:32 PM by dunkers »

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6826
  • Hero Points: 526
Please post your "<config-dir>/25.0.0/templates" data. Just zip it up. That way I've got complete templates as you defined them.

dunkers

  • Senior Community Member
  • Posts: 774
  • Hero Points: 36
Sorry, I thought those were the templates! Zip is attached.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6826
  • Hero Points: 526
I didn't have any problems with your template. I didn't get a Slick-C stack either. Both files get added to the project and I'm not getting a language mode problem when I open either file.

Good thing you sent me your template source files. You didn't store them with your .setemplate file. When you add a template source file, you have the option to copy it to the same directory as the .setemplate file. I'd recommend doing that. I just copied them there and manually edited the .setemplate file and removed that path.

dunkers

  • Senior Community Member
  • Posts: 774
  • Hero Points: 36
Quote
Both files get added to the project

Is this with straight 25.0.0.9 or with the hotfixed version?

Quote
You didn't store them with your .setemplate file.

Indeed not. I learnt some time back not to store things like templates and scripts in the SE data folder since they would be lost if (actually when) the data folder gets deleted.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6826
  • Hero Points: 526
I was running 25.0.0.9. There isn't a hot fix available yet.

Everyone has different ways they use their configuration folder. Whatever works for you is fine.

patrickkox

  • Senior Community Member
  • Posts: 136
  • Hero Points: 6
  • Debian GNU/Linux user
I just did a quick check and for me none of my own Templates are added to a project (.cpp and .h files) when they are added through File -> New Item from Template
They are added when using the Right-Click in the Project Window method.

The method using the File Menu does not show the option to add the new file to the project, but the right-click method does.I have added a screenshot of both windows

dunkers

  • Senior Community Member
  • Posts: 774
  • Hero Points: 36
Quote
They are added when using the Right-Click in the Project Window method.

Ah! Ah-ha!  :o

That explains a lot. I had been right clicking the project folder to add the files, then picking the files generated from the File menu template thing. I didn't realise you could right click the project in the project toolbar (in fact, even after reading your post it took me a while to find that feature - has to be the .vpj and nothing else).

So, looks like I am doing one thing and Graham is doing another, both thinking it's the same.