mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-11-18 20:11:14 +00:00
Always update LS state through Project (#56356)
Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
This commit is contained in:
1 parent
80ab111685
commit
ca7a3af5e6
5 files changed
+378
-1
No files matched your search
@@ -28,6 +28,8 @@ describe("unittests:: tsserver:: plugins:: loading", () => {
|
||||
create(info: ts.server.PluginCreateInfo) {
|
||||
info.session?.addProtocolHandler(testProtocolCommand, request => {
|
||||
session.logger.log(`addProtocolHandler: ${jsonToReadableText(request)}`);
|
||||
// Assume this one needs program
|
||||
info.languageService.getProgram();
|
||||
return {
|
||||
response: testProtocolCommandResponse,
|
||||
};
|
||||
@@ -101,6 +103,41 @@ describe("unittests:: tsserver:: plugins:: loading", () => {
|
||||
baselineTsserverLogs("plugins", "With session and custom protocol message", session);
|
||||
});
|
||||
|
||||
it("when plugins use LS to get program and update is pending", () => {
|
||||
const pluginName = "some-plugin";
|
||||
const aTs: File = {
|
||||
path: "/user/username/projects/project/a.ts",
|
||||
content: `/// <reference path="./b.ts"/>`,
|
||||
};
|
||||
const tsconfig: File = {
|
||||
path: "/user/username/projects/project/tsconfig.json",
|
||||
content: jsonToReadableText({
|
||||
compilerOptions: {
|
||||
plugins: [
|
||||
{ name: pluginName },
|
||||
],
|
||||
},
|
||||
}),
|
||||
};
|
||||
|
||||
const { session, host } = createHostWithPlugin([aTs, tsconfig, libFile]);
|
||||
|
||||
openFilesForSession([aTs], session);
|
||||
// Write the missing file (referenced by 'a.ts') to schedule an update.
|
||||
host.writeFile("/user/username/projects/project/b.ts", "const y = 10;");
|
||||
|
||||
// This should update the language service with a new program.
|
||||
session.executeCommandSeq({
|
||||
command: testProtocolCommand,
|
||||
arguments: testProtocolCommandRequest,
|
||||
});
|
||||
|
||||
// This results in a program update.
|
||||
host.runQueuedTimeoutCallbacks();
|
||||
|
||||
baselineTsserverLogs("plugins", "when plugins use LS to get program and update is pending", session);
|
||||
});
|
||||
|
||||
it("gets external files with config file reload", () => {
|
||||
const aTs: File = { path: `/user/username/projects/myproject/a.ts`, content: `export const x = 10;` };
|
||||
const tsconfig: File = {
|
||||
|
||||
Reference in new issue
Block a user