-
-
Notifications
You must be signed in to change notification settings - Fork 194
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
Cursor API #2727
Labels
Comments
Thank you for collecting all the details and thoughts in this issue. It seems more obvious to me to use the term "cursor". |
Merged
Merged
Available in v6. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Introduction
Once a file is formatted, it can potentially be altered drastically depending on the input. This can disruptive when you are editing code. In order to cope with this, we would introduce a marker API which editors can use. The principle would be that an input position would be captured and could be mapped to an output position afterwards.
Imagine the following:
after formatting:
To link the input
{caret}
to the result{caret}
, we would allow the formatting API to accept thePosition
of thisinput
and return it (when available) in the result of the formatting invocation.API
The cursor type should be a Position type. To easily create this, we could add a
CodeFormatter.MakePosition(line, column)
static member.We should consider working with
Request/Response
types instead of our current tupled API.Technical
The cursor is either inside a text node or outside the tree. We should be able to handle both situations. When the cursor is inside a text node we will be able to return a reliable response. If the cursor is floating somewhere, we will have the same limitations as our trivia-resolving strategy. (A best effort approach)
If the cursor is inside a node, we should try and determine the exact location or pick the start position of the result node.
When multiple defines are in play, we should try and figure out what code fragment was used and use that position of the corresponding combination.
This API should be exposed both in
CodeFormatter
and inFantomas.Client
.Closing thoughts
marker
orcursor
terminology?FormatASTAsync
?//cc @DedSec256
The text was updated successfully, but these errors were encountered: