Skip to content

add in-memory TextDocument implementation #1882

Closed
@josharian

Description

@josharian

Moving the conversation from #1815, where it is buried in a comment thread: #1815 (comment)

For moving to an LSP, and for faster/easier tests not requiring the full VSCode API, it would be helpful to have an in-memory implementation of TextDocument.

#1815 adds a simple one, coded from scratch. But @pokey points out that https://github.com/microsoft/vscode-languageserver-node already has one.

Unfortunately, the TextEditor interface as used by cursorless internally (call this CTE, or Cursorless TextEditor) is larger than the TextEditor interface implemented by https://github.com/microsoft/vscode-languageserver-node (call this VSCTE, for VSCode TextEditor).

Attempts to use VSCTE hit a wall, because missing properties like lineAt and range are extensively used in CTE and are difficult to implement efficiently using VSCTE. Rewriting all of cursorless to use VSCTE directly would (I think) result in less readable, less efficient code.

Attempts to wrap VSCTE in a new object implementing CTE are also not promising: CTE's lineAt returns a TextLine, which VSCTE doesn't have. By the time you set up all the glue, there aren't many savings over just using a mock CTE directly. (VSCTE has some nice performance properties, like lazy line resolution, but IIUC those get destroyed the instant you need to wrap it to make a CTE.)

The question is: As a practical matter, how do I proceed from here? Input requested, although not urgently. (I can keep hacking atop #1815 with the existing implementation for the time being.)

cc @pokey

Related issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions