refactor(flags): migrate lsp download flag (#27699)

This commit is contained in:
Shoubhit Dash
2026-05-15 14:35:31 +05:30
committed by GitHub
parent 202cc863b4
commit 7b370406a9
5 changed files with 102 additions and 52 deletions

View File

@@ -16,6 +16,12 @@ const experimentalTyIt = testEffect(
CrossSpawnSpawner.defaultLayer,
),
)
const disabledDownloadIt = testEffect(
Layer.mergeAll(
LSP.layer.pipe(Layer.provide(Config.defaultLayer), Layer.provide(RuntimeFlags.layer({ disableLspDownload: true }))),
CrossSpawnSpawner.defaultLayer,
),
)
describe("lsp.spawn", () => {
it.live("does not spawn builtin LSP for files outside instance", () =>
@@ -166,4 +172,28 @@ describe("lsp.spawn", () => {
{ config: { lsp: true } },
),
)
disabledDownloadIt.live("passes disableLspDownload to builtin LSP spawn", () =>
provideTmpdirInstance(
(dir) =>
LSP.Service.use((lsp) =>
Effect.gen(function* () {
const pyright = spyOn(LSPServer.Pyright, "spawn").mockResolvedValue(undefined)
try {
yield* lsp.hover({
file: path.join(dir, "src", "inside.py"),
line: 0,
character: 0,
})
expect(pyright).toHaveBeenCalledTimes(1)
expect(pyright.mock.calls[0]?.[2]).toMatchObject({ disableLspDownload: true })
} finally {
pyright.mockRestore()
}
}),
),
{ config: { lsp: true } },
),
)
})