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

isolate the snippet of source code used in formatted error messages #1920

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion flycheck.el
Original file line number Diff line number Diff line change
Expand Up @@ -3864,6 +3864,14 @@ most. It defaults to 20."
"\\s-+" " " (buffer-substring beg (min end (point-max))))
(or max-length 20) nil nil t))))))

;; use isolates and direction markers to make it less likely for text
;; taken from the source to render the error message unreable
;; (sdrawkcab).
(defconst flycheck--format-snippet
(concat "`\N{LEFT-TO-RIGHT MARK}\N{FIRST STRONG ISOLATE}"
"%s\N{POP DIRECTIONAL ISOLATE}\N{LEFT-TO-RIGHT MARK}': ")
"Format string to use on a snippet of source code related to the error.")

(defun flycheck-error-format-message-and-id (err &optional include-snippet)
"Format the message and id of ERR as human-readable string.

Expand All @@ -3877,7 +3885,7 @@ beginning position)."
(concat (and other-file-p (format "In %S:\n" (file-relative-name fname)))
(and include-snippet
(-when-let* ((snippet (flycheck-error-format-snippet err)))
(flycheck--format-message "`%s': " snippet)))
(flycheck--format-message flycheck--format-snippet snippet)))
(or (flycheck-error-message err)
(format "Unknown %S" (flycheck-error-level err)))
(and id (format " [%s]" id)))))
Expand Down