diff options
| author | Yuan Fu | 2025-03-11 01:15:20 -0700 |
|---|---|---|
| committer | Yuan Fu | 2025-03-11 01:35:44 -0700 |
| commit | 0bcc67c8305aa649be54e036fbe475bb82ca3a8b (patch) | |
| tree | cb9c187abd9829bef605532d4d9f31a30191dd4f | |
| parent | 57a213c91cdf4b1739b1068c5dc8ae85f1d5302c (diff) | |
| download | emacs-0bcc67c8305aa649be54e036fbe475bb82ca3a8b.tar.gz emacs-0bcc67c8305aa649be54e036fbe475bb82ca3a8b.zip | |
Handle deleted parser in treesit-explore-mode (bug#76398)
(Unrelated to the topic of the bug, but mentioned in the
thread.)
* lisp/treesit.el (treesit--explorer-refresh-1): New function.
(treesit--explorer-refresh): Handle 'treesit-parser-deleted'
error.
| -rw-r--r-- | lisp/treesit.el | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lisp/treesit.el b/lisp/treesit.el index 36f26ea5825..2d8eebbbff5 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el | |||
| @@ -4525,7 +4525,7 @@ in the region." | |||
| 4525 | (<= (treesit-node-end n) end)) | 4525 | (<= (treesit-node-end n) end)) |
| 4526 | t t))))) | 4526 | t t))))) |
| 4527 | 4527 | ||
| 4528 | (defun treesit--explorer-refresh () | 4528 | (defun treesit--explorer-refresh-1 () |
| 4529 | "Update the syntax tree buffer." | 4529 | "Update the syntax tree buffer." |
| 4530 | (when (and treesit-explore-mode | 4530 | (when (and treesit-explore-mode |
| 4531 | (buffer-live-p treesit--explorer-buffer)) | 4531 | (buffer-live-p treesit--explorer-buffer)) |
| @@ -4576,6 +4576,19 @@ in the region." | |||
| 4576 | (set-window-start window (point)))) | 4576 | (set-window-start window (point)))) |
| 4577 | (set-window-point window pos))))))) | 4577 | (set-window-point window pos))))))) |
| 4578 | 4578 | ||
| 4579 | (defun treesit--explorer-refresh () | ||
| 4580 | "Update the syntax tree buffer." | ||
| 4581 | (condition-case nil | ||
| 4582 | (treesit--explorer-refresh-1) | ||
| 4583 | (treesit-parser-deleted | ||
| 4584 | (when treesit--explorer-buffer | ||
| 4585 | (with-current-buffer treesit--explorer-buffer | ||
| 4586 | (let ((inhibit-read-only t)) | ||
| 4587 | (goto-char (point-min)) | ||
| 4588 | (unless (looking-at "Parser is deleted") | ||
| 4589 | (insert (propertize "Parser is deleted\n" | ||
| 4590 | 'face 'error))))))))) | ||
| 4591 | |||
| 4579 | (defun treesit--explorer-post-command (&rest _) | 4592 | (defun treesit--explorer-post-command (&rest _) |
| 4580 | "Post-command function that runs in the source buffer." | 4593 | "Post-command function that runs in the source buffer." |
| 4581 | (when treesit-explore-mode | 4594 | (when treesit-explore-mode |