Skip to content

Commit

Permalink
fix(syntax): devdocs-lookup causes error 'wrong type characterp' (#255)
Browse files Browse the repository at this point in the history
Why?:
- When looking up some function documentation using devdocs-lookup,
  nim-syntax--raw-string-p errors out with the message 'wrong type charaterp'.
  Because point is at the beginning of the buffer, which makes pos = 1 and thus
  causes char-before to return nil, which then causes the error when calling
  char-syntax on nil.

This change addresses the need by:
- Add guarding when clause

Co-authored-by: Tobias Heinlein <[email protected]>
  • Loading branch information
niontrix and Tobias Heinlein authored Feb 20, 2024
1 parent 1338e5b commit 625cc02
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion nim-syntax.el
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ is used to limit the scan."
(defun nim-syntax--raw-string-p (pos)
"Return non-nil if char of before POS is not word syntax class."
;; See also #212
(eq ?w (char-syntax (char-before pos))))
(when (> pos 1)
(eq ?w (char-syntax (char-before pos)))))

(defun nim-syntax-stringify ()
"Put `syntax-table' property correctly on single/triple double quotes."
Expand Down

0 comments on commit 625cc02

Please sign in to comment.