diff --git a/crates/ide-host/tests/language_smoke.rs b/crates/ide-host/tests/language_smoke.rs index 1b1ff94c3..ead9cf91a 100644 --- a/crates/ide-host/tests/language_smoke.rs +++ b/crates/ide-host/tests/language_smoke.rs @@ -742,38 +742,43 @@ async fn typescript_import_style() { ..TYPESCRIPT }; let smoke = Smoke::start("typescript", &checks).await; - let set = |key: &str, value: &str| { + let lsp = smoke.host.project(WINDOW).unwrap().lsp.clone(); + // Returns once vtsls has the change. A completion that runs before it fills tsserver's + // module specifier cache for that file under the old preferences, and that cache is keyed + // without `autoImportSpecifierExcludeRegexes`, so the file keeps the old answer. + let set = async |key: &str, value: &str| { let scope = ide_workspace::settings::SettingsScope::Project; let key = format!("editor.codeStyle.languages.typescript.{key}"); ops::project::settings_set(&smoke.host, WINDOW, scope, key, value.into()).unwrap(); + lsp.reconfigure().await; }; let alpha = typed("src/app/main.ts", "export const ready", "alphaH"); let beta = typed("src/app/main.ts", "export const ready", "betaW"); let import = |typed, label, result| AutoImport { typed, label, result }; - set("importModuleSpecifier", r#""relative""#); + set("importModuleSpecifier", r#""relative""#).await; smoke.auto_import(import(alpha, "alphaHelper", r#"from "../lib/alpha""#)).await; - set("importModuleSpecifier", r#""non-relative""#); + set("importModuleSpecifier", r#""non-relative""#).await; smoke.auto_import(import(alpha, "alphaHelper", r#"from "@/lib/alpha""#)).await; - set("importModuleSpecifier", r#""relative""#); - set("importModuleSpecifierEnding", r#""index""#); + set("importModuleSpecifier", r#""relative""#).await; + set("importModuleSpecifierEnding", r#""index""#).await; smoke.auto_import(import(beta, "betaWidget", r#"from "./components/index""#)).await; - set("importModuleSpecifierEnding", r#""minimal""#); + set("importModuleSpecifierEnding", r#""minimal""#).await; smoke.auto_import(import(beta, "betaWidget", r#"from "./components""#)).await; // tsserver keeps the auto-import candidates of the file it last completed in until the // program changes; other files see an exclusion at once. - set("autoImportFileExcludePatterns", r#"["**/index.ts"]"#); + set("autoImportFileExcludePatterns", r#"["**/index.ts"]"#).await; smoke.not_offered(typed("src/app/other.ts", "export const other", "betaW"), "betaWidget", "betaWord").await; - set("autoImportSpecifierExcludeRegexes", r#"["lib/alpha$"]"#); + set("autoImportSpecifierExcludeRegexes", r#"["lib/alpha$"]"#).await; smoke.not_offered(typed("src/app/third.ts", "export const third", "alphaH"), "alphaHelper", "alphaHint").await; // Emptied lists reach the server too: the symbols are offered again. - set("autoImportFileExcludePatterns", "[]"); + set("autoImportFileExcludePatterns", "[]").await; let beta = typed("src/app/fourth.ts", "export const fourth", "betaW"); smoke.auto_import(import(beta, "betaWidget", r#"from "./components""#)).await; - set("autoImportSpecifierExcludeRegexes", "[]"); + set("autoImportSpecifierExcludeRegexes", "[]").await; let alpha = typed("src/app/fifth.ts", "export const fifth", "alphaH"); smoke.auto_import(import(alpha, "alphaHelper", r#"from "../lib/alpha""#)).await; }