This repository has been archived by the owner on Oct 12, 2022. It is now read-only.
Add simple lint on save support (closes #21) #68
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I found constant linting updates really distracting while writing code, so I went ahead and implemented this. It uses the same setting format that the built-in PHP linter extension uses:
My first pass at this actually removed the 200ms delay on validation when in onSave mode, but I ran into a couple annoying problems:
onDidChangeContent
is fired afteronDidOpen
and would clear the validation state on openonDidChangeContent
andonDidSave
would be fired around the same time if I quickly saved after making a chance, and this lead to a common race condition where the state would get cleared after a save.I couldn't think of a better way to avoid these issues without tracking a lot of extra state, and figured the 200ms delay is long enough that I don't think you'd ever see a race condition but short enough that it isn't painful.