fernandoescolar / vscode-solution-explorer

This is a Visual Studio Code extension that provides a (.sln) Visual Studio Solution explorer panel..
MIT License
348 stars 73 forks source link

F# support: Add file above and Add file below #270

Closed farlee2121 closed 1 year ago

farlee2121 commented 1 year ago

Motivation

I'd like to smooth the F# experience using Visual studio as a guide. Since F# file order matters, it common to right click a file and use Add Above or Add Below.

image

Desired Solution

I'd like to add context menu options for the most common actions: Create File Above and Create File Below. This excludes the exiting item flow present in Visual Studio and avoids a layer of menu nesting.

These options should only be available for fsproj files, not csproj or other project types. They should be available for any file type within an fsproj, but not on folders or other tree item types. In terms of existing types, only on a ProjectFileTreeItem that belongs to an fsproj project.

Challenges

Language-specific menu items

I explored what it would take to have language-specific context menu items.

With this in mind. It appears the only route forward is to add language to TreeItem.contextValue. However, most commands are common between languages. This means most every command that currently supports ContextValues.projectFile would now need a registration for files in every supported language. Doable, but it has potential to significantly increase complexity of allowed context logic.

Positional Create file

We'd need to modify the createFile call chain to add context for where the file should be added in the proj file. Again, doable, but not a trivial change.

Conclusions

I'm not sure this is worth adding language-specific context items at this time.

268 and #269 may already make for a decent F# experience. Users can add files then open the project file if they want to change the order.

Questions

fernandoescolar commented 1 year ago

This is not exactly the same requirement but I think that by adding the commands to move a file up or down, we cover the requested use case:

Screenshot 2023-03-14 at 21 24 25
farlee2121 commented 1 year ago

That's fantastic! With this it's quick to move a file into place even if it gets created at the bottom.

I opened a PR for a potential missed behavior permission #273

Also, I'm realizing my previous F# sorting conditional was redundant. I guess I must not have done enough testing beforehand. Thanks for catching that!

I think this also sets the pattern for add above/below. I'll take a look.