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

Feature Request: LSP Position to SourcePos helper function #199

Open
Alfus opened this issue Nov 11, 2023 · 1 comment
Open

Feature Request: LSP Position to SourcePos helper function #199

Alfus opened this issue Nov 11, 2023 · 1 comment

Comments

@Alfus
Copy link
Contributor

Alfus commented Nov 11, 2023

LSP provides (0-based) Line and Character for a position:
https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#position
while a ast.SourcePos provides (1-based) Line, Col and (0-based) offset.

A helper function to take a Line and Col, and convert it back to an offset would be very helpful to an implementation that converts from a LSP Position to a SourcePos.

@stefanvanburen
Copy link
Member

Just a note that a reverse of this operation on a similar type (ast.NodeInfo -> protocol.Range) is used by the LSP implementation.

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

No branches or pull requests

2 participants