Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provide a way to maintain cursor locations across formats #149

Open
avh4 opened this issue Apr 15, 2016 · 2 comments
Open

provide a way to maintain cursor locations across formats #149

avh4 opened this issue Apr 15, 2016 · 2 comments

Comments

@avh4
Copy link
Owner

avh4 commented Apr 15, 2016

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 ..." }
@avh4
Copy link
Owner Author

avh4 commented Apr 15, 2016

@benjick FYI, some possible ideas for the future about how to support cursor location transformation for editor plugins

@benjick
Copy link
Contributor

benjick commented Apr 15, 2016

Cool, this is a really good idea!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants