Skip to content

start_server context manager not idempotent #101

@sternj

Description

@sternj

The below is adapted from the Rust tests. I expect both printouts to be identical, but the second prints None.

from multilspy.multilspy_config import MultilspyConfig
from multilspy.multilspy_logger import MultilspyLogger
from multilspy.multilspy_utils import FileUtils
from multilspy import SyncLanguageServer
from tempfile import TemporaryDirectory
import os
from pathlib import Path, PurePath

params = {
    "code_language": "rust",
    "repo_url": "https://github.com/fathyb/carbonyl/",
    "repo_commit": "ab80a276b1bd1c2c8dcefc8f248415dfc61dc2bf",
}
config = MultilspyConfig.from_dict(params)
logger = MultilspyLogger()

with TemporaryDirectory() as temp_dir:
    repo_zip_url = params["repo_url"] + f"archive/{params['repo_commit']}.zip"
    FileUtils.download_and_extract_archive(logger, repo_zip_url, temp_dir, "zip")
    dir_contents = os.listdir(temp_dir)
    assert len(dir_contents) == 1
    source_directory_path = str(Path(temp_dir, dir_contents[0]))
    lsp = SyncLanguageServer.create(config, logger, source_directory_path)
    with lsp.start_server():
        print(
            "FIRST RESULT",
            lsp.request_hover(str(PurePath("src/browser/bridge.rs")), 132, 18),
        )
    with lsp.start_server():
        print(
            "SECOND RESULT",
            lsp.request_hover(str(PurePath("src/browser/bridge.rs")), 132, 18),
        )

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