private async void DocumentSaved(object sender, TextDocumentFileActionEventArgs e) { if (e.FileActionType == FileActionTypes.ContentSavedToDisk) { await LinterService.LintAsync(false, e.FilePath); } }
public void VsTextViewCreated(IVsTextView textViewAdapter) { var textView = EditorAdaptersFactoryService.GetWpfTextView(textViewAdapter); textView.Closed += TextviewClosed; // Both "Web Compiler" and "Bundler & Minifier" extensions add this property on their // generated output files. Generated output should be ignored from linting bool generated; if (textView.Properties.TryGetProperty("generated", out generated) && generated) { return; } if (TextDocumentFactoryService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out _document)) { Task.Run(async() => { if (!LinterService.IsFileSupported(_document.FilePath)) { return; } _document.FileActionOccurred += DocumentSaved; textView.Properties.AddProperty("lint_filename", _document.FilePath); // Don't run linter again if error list already contains errors for the file. if (!TableDataSource.Instance.HasErrors(_document.FilePath)) { await LinterService.LintAsync(false, _document.FilePath); } }); } }