Skip to content

Commit

Permalink
fix: implement getScriptSnapshot only for file to format
Browse files Browse the repository at this point in the history
Should solve the performance regression introduced when fixing #64.

Fixes #67.
  • Loading branch information
simonhaenisch committed Aug 8, 2022
1 parent df10696 commit ee7adda
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
with:
node-version: ${{ matrix.node }}
- run: npm install
- run: npm test -- --timeout=1m
- run: npm test
9 changes: 0 additions & 9 deletions lib/service-host.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,8 @@ const getLanguageServiceHost = (path, content) => {
getScriptVersion: () => '0',
getScriptSnapshot: (filePath) => {
if (filePath === path) {
// for perf, but also needed to make the tests pass because there are no real files involved
return ts.ScriptSnapshot.fromString(content);
}

if (ts.sys.fileExists(filePath)) {
const fileContent = ts.sys.readFile(filePath);

if (fileContent) {
return ts.ScriptSnapshot.fromString(fileContent);
}
}
},
};
};
Expand Down

0 comments on commit ee7adda

Please sign in to comment.