From 38f95e94c37a0c1a86ed3c237532086f2270757c Mon Sep 17 00:00:00 2001 From: Simon Holthausen Date: Tue, 4 Aug 2020 12:27:23 +0200 Subject: [PATCH] (fix) always show svelte.config.js parser error Was swallowed in some cases #422 --- .../plugins/svelte/features/getDiagnostics.ts | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/language-server/src/plugins/svelte/features/getDiagnostics.ts b/packages/language-server/src/plugins/svelte/features/getDiagnostics.ts index 4a8b96c60..ba785e726 100644 --- a/packages/language-server/src/plugins/svelte/features/getDiagnostics.ts +++ b/packages/language-server/src/plugins/svelte/features/getDiagnostics.ts @@ -12,10 +12,14 @@ export async function getDiagnostics( document: Document, svelteDoc: SvelteDocument, ): Promise { + if (svelteDoc.config.loadConfigError) { + return getConfigLoadErrorDiagnostics(svelteDoc.config.loadConfigError); + } + try { return await tryGetDiagnostics(document, svelteDoc); } catch (error) { - return getPreprocessErrorDiagnostics(document, svelteDoc, error); + return getPreprocessErrorDiagnostics(document, error); } } @@ -91,18 +95,10 @@ async function createParserErrorDiagnostic(error: any, document: Document) { /** * Try to infer a nice diagnostic error message from the transpilation error. */ -function getPreprocessErrorDiagnostics( - document: Document, - svelteDoc: SvelteDocument, - error: any, -): Diagnostic[] { +function getPreprocessErrorDiagnostics(document: Document, error: any): Diagnostic[] { Logger.error('Preprocessing failed'); Logger.error(error); - if (svelteDoc.config.loadConfigError) { - return getConfigLoadErrorDiagnostics(svelteDoc.config.loadConfigError); - } - if (document.styleInfo && error.__source === TranspileErrorSource.Style) { return getStyleErrorDiagnostics(error, document); }