mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
Fix treesit-parse-string crash (bug#71012)
Parsing a large file with treesit-parse-string and then printing the returned node crashes Emacs, because with-temp-buffer kills the temp buffer when treesit-parse-string returns, and print.c tries to access the node's position in the killed buffer. * lisp/treesit.el (treesit-parse-string): Don't use with-temp-buffer.
This commit is contained in:
parent
20af58d3a1
commit
00360258ca
1 changed files with 7 additions and 4 deletions
|
|
@ -122,10 +122,13 @@ of max unsigned 32-bit value for byte offsets into buffer text."
|
|||
(defun treesit-parse-string (string language)
|
||||
"Parse STRING using a parser for LANGUAGE.
|
||||
Return the root node of the syntax tree."
|
||||
(with-temp-buffer
|
||||
(insert string)
|
||||
(treesit-parser-root-node
|
||||
(treesit-parser-create language))))
|
||||
;; We can't use `with-temp-buffer' because it kills the buffer when
|
||||
;; returning from the form.
|
||||
(let ((buf (generate-new-buffer " *treesit-parse-string*")))
|
||||
(with-current-buffer buf
|
||||
(insert string)
|
||||
(treesit-parser-root-node
|
||||
(treesit-parser-create language)))))
|
||||
|
||||
(defvar-local treesit-language-at-point-function nil
|
||||
"A function that returns the language at point.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue