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 auto indentation when pressing the : or Enter keys #671

@DonJayamanne

Description

@DonJayamanne
  • Today indentation of code is implemented within the extension (and buggy, as we do not have the token/AST information, etc)
  • The C# extension supports similar features (indentation changes) when you type the character }.
    • The C# extension is TS code, that sends requests to a .NET process over a protocol.
    • I.e. .NET is performing the necessary formatting, and sending back the formatted code (asynchronously) back to the TS code.
  • We need the same thing, when users type the character :.
    • I.e. TS can send a custom request to language server, get the response back and send formatted code to VSC.

I.e. if C# extension (using the .NET code, async communication via a protocol) can do this, then how about we do the same thing (using LSP over custom request).

https://github.com/OmniSharp/omnisharp-vscode/blob/f0a0336ced8cb44f78bdee88120bfe9d62a596c0/src/features/formattingEditProvider.ts#L44

export async function formatAfterKeystroke(server: OmniSharpServer, request: protocol.FormatAfterKeystrokeRequest, token: vscode.CancellationToken) {
https://github.com/OmniSharp/omnisharp-vscode/blob/f0a0336ced8cb44f78bdee88120bfe9d62a596c0/src/omnisharp/utils.ts#L42

Related to microsoft/vscode-python#481

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions