Skip to content

In v2, allow a way to convert from document.source index to Position #534

@itsmeknt

Description

@itsmeknt

Hello! I have a feature request for v2.

Background:
TextDocument.offset_at_position(), already implemented here, is a nice way to get the character index of document.source given the client's types.Position struct.

Request:
It would be nice to also have the reverse lookup. Given the character indexes of document.source, I would like a way to decode that into types.Position so that I easily specify in the response, for example, which text the inline completion will replace.

I couldn't find a way to do this by looking through the source code, so I implemented a hacky solution.

I also noticed the jedi-language-server application created their own approach as well here

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions