Skip to content

client->server request: Join Lines #992

@matklad

Description

@matklad

Meta: I am in the process of formalizing protocol extensions, used by rust-analyzer. I will be filing issues for generally useful extensions. Here's the doc where we will document our extensions.

joinLines

Server Capability: { "joinLines": boolean }

This request is send from client to server to handle "Join Lines" editor action.

Method: experimental/JoinLines

Request:

interface JoinLinesParams {
    textDocument: TextDocumentIdentifier,
    /// Currently active selections/cursor offsets.
    /// This is an array to support multiple cursors.
    ranges: Range[],
}

Response:

TextEdit[]

Example

fn main() {
    /*cursor here*/let x = {
        92
    };
}

experimental/joinLines yields (curly braces are automagiacally removed)

fn main() {
    let x = 92;
}

Unresolved Question

  • What is the position of the cursor after joinLines?
    Currently this is left to editor's discretion, but it might be useful to specify on the server via snippets.
    However, it then becomes unclear how it works with multi cursor.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions