Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/curvy-boats-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'svelte-language-server': patch
'svelte-check': patch
---

fix: prevent config loading message in svelte-check --incremental
8 changes: 6 additions & 2 deletions packages/language-server/src/lib/documents/Document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,14 @@ export class Document extends WritableDocument {

constructor(
public url: string,
public content: string
public content: string,
loadConfig = false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we do it the other way around? load config by default. I think this would result in less changed code locations.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a lot of new Document calls in the test, and most of them don't need the config. But the performance difference in config loading during the test isn't very noticeable, so it's not that important. Would you prefer it to be skipLoadConfig instead?

) {
super();
this.configPromise = configLoader.awaitConfig(this.getFilePath() || '');
this.configPromise = loadConfig
? configLoader.awaitConfig(this.getFilePath() || '')
: Promise.resolve(undefined);

this.updateDocInfo();
}

Expand Down
2 changes: 1 addition & 1 deletion packages/language-server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export function startServer(options?: LSOptions) {
}

const docManager = new DocumentManager(
(textDocument) => new Document(textDocument.uri, textDocument.text)
(textDocument) => new Document(textDocument.uri, textDocument.text, /*loadConfig*/ true)
);
const configManager = new LSConfigManager();
const pluginHost = new PluginHost(docManager);
Expand Down
3 changes: 2 additions & 1 deletion packages/language-server/src/svelte-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export function mapSvelteCheckDiagnostics(
};
}
): Diagnostic[] {
Logger.setLogErrorsOnly(true);
const document = new Document(pathToUrl(sourcePath), sourceText);
const snapshot = DocumentSnapshot.fromDocument(document, {
parse: document.compiler?.parse,
Expand Down Expand Up @@ -74,7 +75,7 @@ export interface SvelteCheckOptions {
*/
export class SvelteCheck {
private docManager = new DocumentManager(
(textDocument) => new Document(textDocument.uri, textDocument.text)
(textDocument) => new Document(textDocument.uri, textDocument.text, /*loadConfig*/ true)
);
private configManager = new LSConfigManager();
private pluginHost = new PluginHost(this.docManager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('Svelte Plugin', () => {
prettierConfig?: any,
{ trusted = true, documentUri = 'file:///hello.svelte' } = {}
) {
const document = new Document(documentUri, content);
const document = new Document(documentUri, content, /*loadConfig*/ true);
const docManager = new DocumentManager(() => document);
const pluginManager = new LSConfigManager();
pluginManager.updateIsTrusted(trusted);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ describe('SveltePlugin#getCodeAction', () => {
const filePath = path.join(testDir, filename);
const document = new Document(
pathToUrl(filePath),
filename ? fs.readFileSync(filePath)?.toString() : ''
filename ? fs.readFileSync(filePath)?.toString() : '',
/*loadConfig*/ true
);
const svelteDoc = new SvelteDocument(document);
const codeAction = await getCodeActions(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ describe('SveltePlugin#getDiagnostics', () => {
function setupFromFile(filename: string) {
const testDir = path.join(__dirname, '..');
const filePath = path.join(testDir, 'testfiles', filename);
const document = new Document(pathToUrl(filePath), fs.readFileSync(filePath, 'utf-8'));
const document = new Document(
pathToUrl(filePath),
fs.readFileSync(filePath, 'utf-8'),
/*loadConfig*/ true
);
const pluginManager = new LSConfigManager();
const plugin = new SveltePlugin(pluginManager);
return { plugin, document };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { getPackageInfo } from '../../../../../src/importPackage';

function setup(workspaceDir: string, filePath: string) {
const docManager = new DocumentManager(
(textDocument) => new Document(textDocument.uri, textDocument.text)
(textDocument) => new Document(textDocument.uri, textDocument.text, /*loadConfig*/ true)
);
const configManager = new LSConfigManager();
const lsAndTsDocResolver = new LSAndTSDocResolver(
Expand Down
Loading