From 18c4f4de86ce2ab7053cce0f44c08bbfaeeba3d8 Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Tue, 18 Jul 2023 20:31:34 +0200 Subject: [PATCH] feat: eagerly validate Always validate, indicate results in overlay. Toggle overlays on button click. --- lib/Linting.js | 19 +++++++------------ test/spec/LintingSpec.js | 2 +- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/lib/Linting.js b/lib/Linting.js index 848caed..fbc4e82 100644 --- a/lib/Linting.js +++ b/lib/Linting.js @@ -75,9 +75,7 @@ export default function Linting( 'linting.configChanged', 'linting.toggle' ], LOW_PRIORITY, function(e) { - if (self.isActive()) { - self.update(); - } + self.update(); }); eventBus.on('linting.toggle', function(event) { @@ -269,7 +267,10 @@ Linting.prototype.update = function() { add = assign(add, update); self._clearOverlays(); - self._createIssues(add); + + if (self.isActive()) { + self._createIssues(add); + } self._issues = newIssues; @@ -516,7 +517,7 @@ Linting.prototype._setButtonState = function(issues) { var label = this._translate( (errors || warnings) ? '{errors} Errors, {warnings} Warnings' - : 'Toggle Linting', + : 'No Issues', { errors: String(errors), warnings: String(warnings), @@ -548,12 +549,6 @@ Linting.prototype._setButtonState = function(issues) { Linting.prototype._updateButton = function() { - if (!this.isActive()) { - this._setButtonState('inactive', 0, 0); - - return; - } - var errors = 0, warnings = 0, infos = 0; @@ -582,7 +577,7 @@ Linting.prototype._createButton = function() { var self = this; this._button = domify( - '' + '' ); this._button.addEventListener('click', function() { diff --git a/test/spec/LintingSpec.js b/test/spec/LintingSpec.js index 054222e..429cc59 100644 --- a/test/spec/LintingSpec.js +++ b/test/spec/LintingSpec.js @@ -702,7 +702,7 @@ describe('linting - i18n', function() { document.body.appendChild(el); const translations = { - 'Toggle linting': 'Перемкнути перевірку', + 'Toggle linting overlays': 'Перемкнути перевірку', 'Process is missing end event': 'У процеса відсутня завершальна подія', '{errors} Errors, {warnings} Warnings': '{errors} помилок, {warnings} попередженнь' };