Closed yilei closed 9 months ago
@yilei If you are interested in providing a PR we are open for this. This code here needs to be updated to pass in the line range. https://github.com/microsoft/vscode-black-formatter/blob/b4c47350772ca2f423a66a8c749b374f9c071a10/bundled/tool/lsp_server.py#L105-L111
There is also proposed support for multiple line ranges via format ranges. That support is still not in pygls
, that will allow us to add the multi-range support as well.
Thanks for the pointer. Any pointers how to build my local version of the extension and have VS Code use it? The Contributing Guide doesn't mention this.
You can run this to build it locally:
> npm run package
I also update the contributing guide. The requirements were a bit out dated.
@karthiknadig Thanks for updating. But I think the correct command to build the vsix package is npm run vsce-package
, took me a while to poke around the source since I'm not familiar with npm.
@yilei Were you able to add this support?
@karthiknadig I'm able to make it work, but I had a hard time writing tests and make the tests run. Should I still send the PR without tests?
Yes. I can help with tests.
https://github.com/psf/black/pull/4020 added a
--line-ranges=
option to Black and is now released in 23.11.0. See https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#line-rangesVS Code should now be able to properly support the "Format Selection" command.
Previously related: https://github.com/microsoft/vscode-black-formatter/issues/176