Skip to content

Commit

Permalink
fix: #203 - Source file will now be marked as "saved" when updating f…
Browse files Browse the repository at this point in the history
…rom file system.
  • Loading branch information
dsherret committed Jan 6, 2018
1 parent e8c2339 commit fa0dd2c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/compiler/file/SourceFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,7 @@ export class SourceFile extends SourceFileBase<ts.SourceFile> {
return FileSystemRefreshResult.NoChange;

this.replaceText([0, this.getEnd()], fileText);
this.setIsSaved(true); // saved when loaded from file system
return FileSystemRefreshResult.Updated;
}
}
2 changes: 2 additions & 0 deletions src/tests/compiler/file/sourceFileTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,7 @@ function myFunction(param: MyClass) {
host.writeFileSync(filePath, newText);
expect(sourceFile.refreshFromFileSystemSync()).to.equal(FileSystemRefreshResult.Updated);
expect(firstChild.wasForgotten()).to.be.true;
expect(sourceFile.isSaved()).to.be.true;
expect(sourceFile.getFullText()).to.equal(newText);
host.deleteSync(filePath);
expect(sourceFile.refreshFromFileSystemSync()).to.equal(FileSystemRefreshResult.Deleted);
Expand Down Expand Up @@ -880,6 +881,7 @@ function myFunction(param: MyClass) {
await host.writeFile(filePath, newText);
expect(await sourceFile.refreshFromFileSystem()).to.equal(FileSystemRefreshResult.Updated);
expect(firstChild.wasForgotten()).to.be.true;
expect(sourceFile.isSaved()).to.be.true;
expect(sourceFile.getFullText()).to.equal(newText);
await host.delete(filePath);
expect(await sourceFile.refreshFromFileSystem()).to.equal(FileSystemRefreshResult.Deleted);
Expand Down

0 comments on commit fa0dd2c

Please sign in to comment.