TypeStrong / atom-typescript

The only TypeScript package you will ever need
https://atom.io/packages/atom-typescript
MIT License
1.13k stars 205 forks source link

feat/check-all-files-on-save #1535

Closed firejune closed 4 years ago

firejune commented 4 years ago

When this option enabled, It will be report all problems in current project when on file saved.

lierdakil commented 4 years ago

Right. Sorry for the delay, I was travelling last week, didn't really find the time to take a look.

This looks good, but I do have a suggestion. It is generally not a good idea to rely on atom.workspace.getActiveTextEditor(), especially in async code, especially from a TextBuffer event (multiple editors can share the same buffer), since it can, under some hard-to-reproduce circumstances, return a wrong editor instance. That's the reason why in my "mock code" I suggested changes to typescriptEditorPane.ts, and not to typescriptBuffer.ts. So I suggest moving the code that runs checkAllFiles to typescriptEditorPane.ts, and avoiding getActiveTextEditor altogether.