Skip to content
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

fix(host): getScriptSnapshot must also call fileNames.add #364

Merged
merged 1 commit into from
Jun 24, 2022
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
fix(host): getScriptSnapshot must also call fileNames.add
- the `fileNames` Set that was previously introduced in c86e07b caused a regression during watch mode
  - this is because `setSnapshot` was updated to call `this.fileNames.add`, but `getScriptSnapshot` was not
    - instead of updating both to be the same, we can just call `setSnapshot` from `getScriptSnapshot` as this code is supposed to be identical
      - also rename `data` -> `source` for consistency and clarity (`source` is a more specific name)
  • Loading branch information
agilgur5 committed Jun 22, 2022
commit 5453ad74673686177214cf7f02065dea051855a0
10 changes: 3 additions & 7 deletions src/host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ export class LanguageServiceHost implements tsTypes.LanguageServiceHost
this.service = service;
}

public setSnapshot(fileName: string, data: string): tsTypes.IScriptSnapshot
public setSnapshot(fileName: string, source: string): tsTypes.IScriptSnapshot
{
fileName = normalize(fileName);

const snapshot = tsModule.ScriptSnapshot.fromString(data);
const snapshot = tsModule.ScriptSnapshot.fromString(source);
this.snapshots[fileName] = snapshot;
this.versions[fileName] = (this.versions[fileName] || 0) + 1;
this.fileNames.add(fileName);
Expand All @@ -47,11 +47,7 @@ export class LanguageServiceHost implements tsTypes.LanguageServiceHost

const source = tsModule.sys.readFile(fileName);
if (source)
{
this.snapshots[fileName] = tsModule.ScriptSnapshot.fromString(source);
this.versions[fileName] = (this.versions[fileName] || 0) + 1;
return this.snapshots[fileName];
}
return this.setSnapshot(fileName, source);

return undefined;
}
Expand Down