Skip to content

fix: misleading error message about missing config when opening new file #935

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 9, 2020
Merged
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
9 changes: 8 additions & 1 deletion server/src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ export class Session {
const {configFileName} = this.projectService.openClientFile(scriptInfo.fileName);
if (!configFileName) {
// Failed to find a config file. There is nothing we could do.
this.connection.console.error(`No config file for ${scriptInfo.fileName}`);
return;
}
project = this.projectService.findProject(configFileName);
Expand Down Expand Up @@ -266,7 +267,13 @@ export class Session {
this.connection.console.error(configFileErrors.map(e => e.messageText).join('\n'));
}
if (!configFileName) {
this.connection.console.error(`No config file for ${filePath}`);
// It is not really an error if there is no config file, because the
// first call to openClientFile() will create a project for the file if
// it does not exist, but the method will not return the config filename.
// In subsequent operations, we'll call this.getDefaultProjectForScriptInfo(),
// and there we make a second call to openClientFile(). By then, since
// the project has already been created, we will receive the config
// filename, and we can attach the file to the project it belongs to.
return;
}
const project = this.projectService.findProject(configFileName);
Expand Down