Add support for Format Document command in .feature files
Add support for using Visual Studio's 'Format Document' command (Ctrl-K, Ctrl-D) for gherkin .feature files.
This should be configurable via the global options menu.
Yes, this is on my list too. @wooger Would you be interested to contribute? I could guide you with some design ideas.
@gasparnagy I would be really interested in contributing. I partially implemented this feature for Specflow extension for VS and I really need to use it in my everyday job :)
@littlegenius666 Great! I would be happy to support you!
The solution here can be built up based on
- CommentCommand - this shows how to hook on a standard VS command
- AutoFormatTableCommand - this shows how text can be replaced.
Things to note:
- When we make the nice formatted version, we have to use the right newline character and the right indentation. See here how this can be obtained from VS. (The old VS extension always used CRLF causing some troubles.)
- In long term, the formatting rules (whether steps should be indented, etc.) should be configurable (Deveroom already has a configuration infrastructure that can be changed using a
deveroom.jsonconfig file). But for the first version, we can use fix rules.
Tests:
I try to be pretty strict on having enough/proper testing on all added feature. We have a pretty nice infrastructure where we can test editor features using a stub editor without launching VS. They are fast and support test-first development very well -- I encourage you to try it.
The AutoFormatTableCommand.feature is probably a good example to start the scenarios for the "format document" command as well, but you can take a look at the other scenarios as well in the Commands folder.
I only cover the most relevant illustrative examples as BDD scenarios, for the detailed data variation or edge cases, I use unit tests, like the AutoFormatTableCommandTests for the auto format.
You can also send a work-in-progress PR as well and I can help you out or give early feedback.
Of course I am also interested in any feedback about the development / contribution experience -- how to make it easier for anyone to contribute.
I would like to suggest allowing the user to put their feature file style configuration into the .editorconfig, should I raise this as another enhancement proposal?
Hi! What is the status of this issue now? We with the team are waiting for these changes very much! Unfortunately, we always have problems related to the formatting of tables....
Any news on this one? As this feature is really missing compared to the Specflow extension.
As you might know, Deveroom has been used as a baseline for the SpecFlow for Visual Studio 2022 product (https://github.com/SpecFlowOSS/SpecFlow.VS/) and the implementation of new features and improvements continues there and the format document has been implemented there.
The easiest recommendation to switch to VS2022, where you will get the "Deveroom-experience", but with extra features. If this is not feasible feel free to submit a PR for Deveroom. The format document feature can be done based on https://github.com/SpecFlowOSS/SpecFlow.VS/blob/main/SpecFlow.VisualStudio/Editor/Commands/AutoFormatDocumentCommand.cs