mrward / typescript-addin

TypeScript addin for MonoDevelop and Xamarin Studio
MIT License
29 stars 9 forks source link

Compiled JS file not updating if already open #14

Closed Layoric closed 8 years ago

Layoric commented 8 years ago

Nice addin and thanks for keeping it up to date :+1:

I'm noticing an issue with the generated .js file when compiling on save where if the .js file is open in Xamarin Studio, it doesn't reflect changes from compiling the corresponding .ts file.

Reproduction steps: 1.Create/add to project myclass.ts 2.Create simple class

class MyClass { }

3.Save (with option to compile on save enabled). 4.Add myclass.js to project and open it. 5.Modify myclass.ts and save 6.myclass.js hasn't updated since first opened.

I'm not sure the best way to approach the problem, as when I've done it in the past for an Xamarin Studio addin, the best way I could find was to force the IDE to close and reopen the file, like so. Any ideas?

Using Xamarin Studio 5.10.1 (build 6) and addin version 0.9 on OSX

mrward commented 8 years ago

The TypeScript addin should call the FileService.NotifyFileChanged after it compiles the file, but currently it is not doing that. This should cause the file to automatically be reloaded in the text editor.

Layoric commented 8 years ago

@mrward Thanks for that info! I had trouble with FileService.NotifyFileChanged, in the past but testing it now, seems to work well :+1:

mrward commented 8 years ago

FileService.NotifyFileChanged does not always cause the file to be reloaded even if the autoreload flag is set. In Xamarin Studio 5 when FileService.NotifyFileChanged is called the changed file is automatically reloaded by the FileRegistry class. However if FileService.NotifyFileChanged is called when the document is being saved then all file changes are ignored since the TrackFileChanges flag is set to false.

This is a problem for the TypeScript addin since it uses the FileService.FileChanged event when compile on save is being used. So the TypeScript addin may have to reload the file itself.