Closed timheuer closed 2 years ago
Ok, I am impressed! Looks like a very simple fix. I really hope there are no side effects. There are 3 extensions I use almost every day and this is one of them.
The other ones are Open Command Line [ Alt + Space ] and Extension Manager. In my view, all 3 should already by built-in features in VS.
Working through a side-effect issue right now in subfolders (and caret positioning is a secondary problem). May take a bit to debug why AddFromTemplate
change is having an issue with subfolders :-(
Blocked by this scenario bug: https://github.com/dotnet/roslyn/issues/58311
Ok, this appears to work...now on to the caret placement logic change 🤔🤔🤔🤔 -- THANK YOU @davidwengier for helping to take a look and confirming where to change.
@madskristensen I did a bunch of "works on my machine" testing but would be good for any other eyes on it. See note about the caret template capability though. Since formatting happens after project system adding, the placeholder caret positioner is already gone and the position
is now invalid and will just go to index=0. This is the same behavior as item templates today in this same method.
It works in SDK style .NET projects, but not in .NET Framework legacy projects. Looking into it now...
😡 CPS doesn't like a full path for AddFolder
as it has a :
char in it...
Yeah, I got it almost working with relative paths. It seems to work everywhere, except for multiple subfolders on legacy .NET projects
It appears that AddFolder
for legacy doesn't like a full new nested path eg folder1\folder2\folder3
whereas CPS allows this and will create all folders in the nested path. AddFile
and AddFromTemplate
seem to have diff behavior from legacy vs. CPS :-(
I'm doing a loop to add each subfolder individually before adding the file. That should work, but will be slower
Could also just be a timing thing. CPS will see the changes on disk and add the files/folders itself because of the default globs in the SDK, so if that happens first then AddFolder might not even be doing anything.
Making this change will now run any
.editorconfig
rules in the project and thus things like honoring file-scoped namespaces. Unknown other side-affects on other scenarios, but this works for .cs :-)With this change and existence of
.editorconfig
the rules will apply. This loses the template caret position behavior however, but mimics existing behavior of item templates (add class) where caret position is at 0. It maintains the template behavior if not going through the formatter though.