Skip to content

Commit e67008b

Browse files
authored
Allow Flycheck to determine a diagnostic end position when needed. (#4429)
When a Language Server doesn't support an end position for a diagnostic (by specifying an end position the same as the start position) Flycheck should be asked to compute the end position using it's `flycheck-highlighting-mode` setting. This is accomplished by passing nil as the end-column to `flycheck-error-new`. This provides consistent behavior between Flymake and Flycheck as the Flymake integration already checks for this condition and uses it's similar functionality (i.e., `flymake-diag-region`) to compute an end position.
1 parent 4a0aec0 commit e67008b

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lsp-diagnostics.el

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,12 @@ CALLBACK is the status callback passed by Flycheck."
156156

157157
(->> (lsp--get-buffer-diagnostics)
158158
(-map (-lambda ((&Diagnostic :message :severity? :tags? :code? :source?
159-
:range (&Range :start (&Position :line start-line
160-
:character start-character)
161-
:end (&Position :line end-line
162-
:character end-character))))
159+
:range (&Range :start (start &as &Position
160+
:line start-line
161+
:character start-character)
162+
:end (end &as &Position
163+
:line end-line
164+
:character end-character))))
163165
(flycheck-error-new
164166
:buffer (current-buffer)
165167
:checker checker
@@ -171,7 +173,8 @@ CALLBACK is the status callback passed by Flycheck."
171173
:line (lsp-translate-line (1+ start-line))
172174
:column (1+ (lsp-translate-column start-character))
173175
:end-line (lsp-translate-line (1+ end-line))
174-
:end-column (1+ (lsp-translate-column end-character)))))
176+
:end-column (unless (lsp--position-equal start end)
177+
(1+ (lsp-translate-column end-character))))))
175178
(funcall callback 'finished)))
176179

177180
(defun lsp-diagnostics--flycheck-buffer ()

0 commit comments

Comments
 (0)