Skip to content

provide a way to maintain cursor locations across formats #149

@avh4

Description

@avh4

When an IDE plugin runs elm-format, it ideally wants to maintain the cursor and scroll position of the buffer. The plugin could perform some kind of estimation of where the cursor and scroll should be placed after the file is formatted, but it would be more appropriate for elm-format to calculate how cursor locations in the input correspond to cursor locations in the output.

Here is a possible API:

  • a command line argument is added allowing plugins to provide buffer locations
  • when given buffer locations to transform, elm-format will produce JSON containing the transformed locations

elm-format --cursor 10,4 --cursor 104,32 --stdin

output:

{ "cursors": [ [11,4], [107, 36] ], "content": "module ..." }

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions