Minor improvement for tree-sitter explorer
If you open an empty python buffer and type 1 + 2 a b Currently the explorer only displays the top-level node at point, ie, only 1 + 2, only a, or only b. That's kind of awkward, so if the buffer is small, show the entire parse tree. * lisp/treesit.el (treesit--explorer-refresh): See above.
This commit is contained in:
parent
ef87c75566
commit
1f8ad353d9
1 changed files with 9 additions and 5 deletions
|
@ -2415,11 +2415,15 @@ in the region."
|
||||||
(window-start) (window-end) treesit--explorer-language))
|
(window-start) (window-end) treesit--explorer-language))
|
||||||
;; Only highlight the current top-level construct.
|
;; Only highlight the current top-level construct.
|
||||||
;; Highlighting the whole buffer is slow and unnecessary.
|
;; Highlighting the whole buffer is slow and unnecessary.
|
||||||
(top-level (treesit-node-first-child-for-pos
|
;; But if the buffer is small (ie, used in playground
|
||||||
root (if (eolp)
|
;; style), just highlight the whole buffer.
|
||||||
(max (point-min) (1- (point)))
|
(top-level (if (< (buffer-size) 4000)
|
||||||
(point))
|
root
|
||||||
t))
|
(treesit-node-first-child-for-pos
|
||||||
|
root (if (eolp)
|
||||||
|
(max (point-min) (1- (point)))
|
||||||
|
(point))
|
||||||
|
t)))
|
||||||
;; Only highlight node when region is active, if we
|
;; Only highlight node when region is active, if we
|
||||||
;; highlight node at point the syntax tree is too jumpy.
|
;; highlight node at point the syntax tree is too jumpy.
|
||||||
(nodes-hl
|
(nodes-hl
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue