Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support multiline diagnostics #757

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions lsp-bridge-diagnostic.el
Original file line number Diff line number Diff line change
Expand Up @@ -331,13 +331,15 @@ You can set this value with `(2 3 4) if you just need render error diagnostic."
(message (plist-get diagnostic :message))
(start (plist-get range :start))
(end (plist-get range :end))
(line (1+ (plist-get start :line)))
(start-line (1+ (plist-get start :line)))
(start-column (plist-get start :character))
(end-line (1+ (plist-get end :line)))
(end-column (plist-get end :character))
(line-content (with-current-buffer current-buffer
(save-excursion
(goto-line line)
(buffer-substring-no-properties (line-beginning-position) (line-end-position))))))
(goto-line start-line)
(buffer-substring-no-properties (line-beginning-position) (line-end-position)))))
(content-end-column (if (eq start-line end-line) end-column (string-width line-content))))
(insert (concat "\033[93m" (format "%s %s" (1+ diagnostic-counter) message) "\033[0m" "\n"))

;; `start' point and `end' point will same if the diagnostic message is for a location rather than region.
Expand All @@ -346,13 +348,16 @@ You can set this value with `(2 3 4) if you just need render error diagnostic."
(setq end-column (1+ end-column)))

(insert (format "%s:%s:%s\n\n"
line
start-line
start-column
(concat (substring line-content 0 start-column)
"\033[94m"
(substring line-content start-column end-column)
(substring line-content start-column content-end-column)
(let ((line-difference (- end-line start-line)))
(unless (eq line-difference 0)
(format "... (+%d line%s)" line-difference (when (> line-difference 1) "s"))))
"\033[0m"
(substring line-content end-column))))
(substring line-content content-end-column))))

(setq diagnostic-counter (1+ diagnostic-counter))))
(lsp-bridge-ref-popup (buffer-string) diagnostic-counter))))
Expand Down
Loading