Skip to content

Commit

Permalink
Fix flycheck-error-level-interesting-p
Browse files Browse the repository at this point in the history
According to its docstring, `flycheck-error-level-interesting-p` should
return true if there are no errors as _or more severe than_
`flycheck-navigation-minimum-level`. Currently, however, it only checks
if there are any errors exactly as severe as
`flycheck-navigation-minimum-level` (via
`flycheck-has-current-errors-p`). This patch:

* improves the documentation of
  * `flycheck-has-current-errors-p`
  * `flycheck-has-errors-p`
* introduces two new functions
  * `flycheck-has-current-errors-atleast-p`
  * `flycheck-has-errors-atleast-p`
* Changes `flycheck-error-level-interesting-p` to use
  `flycheck-has-current-errors-atleast-p`, instead of its "exact"
  sibling, bringing its actual behavior in line with its documented
  behavior
  • Loading branch information
KevOrr committed Mar 29, 2021
1 parent f8c679f commit c312490
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions flycheck.el
Original file line number Diff line number Diff line change
Expand Up @@ -4652,17 +4652,34 @@ level."
(flycheck-has-max-errors-p flycheck-current-errors level))

(defun flycheck-has-errors-p (errors level)
"Determine if there are any ERRORS with LEVEL."
"Determine if there are any ERRORS with exactly LEVEL."
(seq-some (lambda (e) (eq (flycheck-error-level e) level)) errors))

(defun flycheck-has-errors-atleast-p (errors level)
"Determine if there are any ERRORS with at least LEVEL."
(seq-some (lambda (e)
(>= (flycheck-error-level-severity (flycheck-error-level e))
(flycheck-error-level-severity level)))
errors))

(defun flycheck-has-current-errors-p (&optional level)
"Determine if the current buffer has errors with LEVEL.
"Determine if the current buffer has any errors with exactly LEVEL.

If LEVEL is omitted if the current buffer has any errors at all."
If LEVEL is omitted, then return whether the current buffer has any errors at
all."
(if level
(flycheck-has-errors-p flycheck-current-errors level)
(and flycheck-current-errors t)))

(defun flycheck-has-current-errors-atleast-p (&optional level)
"Determine if the current buffer has any errors with at least LEVEL.

If LEVEL is omitted, then return whether the current buffer has any errors at
all."
(if level
(flycheck-has-errors-atleast-p flycheck-current-errors level)
(and flycheck-current-errors t)))


;;; Error overlays in the current buffer
(defvar-local flycheck--last-overlay-index 0
Expand Down Expand Up @@ -4851,7 +4868,7 @@ no errors as or more severe than `flycheck-navigation-minimum-level'."
(-if-let (min-level flycheck-navigation-minimum-level)
(or (<= (flycheck-error-level-severity min-level)
(flycheck-error-level-severity (flycheck-error-level err)))
(not (flycheck-has-current-errors-p min-level)))
(not (flycheck-has-current-errors-atleast-p min-level)))
t)))

(defun flycheck-next-error-pos (n &optional reset)
Expand Down

0 comments on commit c312490

Please sign in to comment.