Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Implement on-type block formatting #165

Closed

Description

The VS Code extension provides an on-type formatter that triggers on : which allows for block formatting. For example, you can hit colon after the else in the following code:

if x:
    pass
    else

Which will then be reformatted into:

if x:
    pass
else:

This functionality should be implemented in language server for feature parity. The language server may even be able to handle more cases correctly than the extension's use of regex, since we have access to an AST.

Since on-type formatting has only one entrypoint (DocumentOnTypeFormatting), that function would need to map trigger characters to the right handler. A nicety would be to have a Dictionary of handlers, then produce the DocumentOnTypeFormattingOptions's trigger character members from that dictionary rather than needing to remember to change the characters in two different files.

Related to microsoft/vscode-python#2714.

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions