diff options
| author | Yuan Fu | 2022-05-13 13:38:21 -0700 |
|---|---|---|
| committer | Yuan Fu | 2022-05-13 14:36:37 -0700 |
| commit | 78df03329d1e942d5617c0f09f264792e24a063d (patch) | |
| tree | badb03713f25a02e0d3d74020fa1878fd54d6b43 /test/src | |
| parent | eebe5a1d6114ed54eb3cdd5576f43da76590b8fa (diff) | |
| download | emacs-78df03329d1e942d5617c0f09f264792e24a063d.tar.gz emacs-78df03329d1e942d5617c0f09f264792e24a063d.zip | |
Redefine treesit-node-at
The old 'treesit-node-at' becomes 'treesit-node-on'. The new
'treesit-node-at' has slightly different semantics. Now
'treesit-node-on' gets the smallest node covering a range and
'treesit-node-at' gets the smallest node after a position.
The reason of change can be found in the docstring of
'treesit-node-on' (the BEWARE part): its result can be sometimes
surprising/unexpected.
* doc/lispref/parsing.texi (Retrieving Node): Update manual.
* lisp/treesit.el (treesit-node-at): Change to new definition.
(treesit-node-on): Inherits the old definition of
'treesit-node-at'. Parameter END is now mandatory.
(treesit-language-at, treesit-node-field-name): Use the new '-on'
function.
(treesit-font-lock-fontify-region, treesit-simple-indent-presets,
treesit-indent): Use the new '-at' function.
* test/src/treesit-tests.el (treesit-node-supplemental): Update tests.
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/treesit-tests.el | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/test/src/treesit-tests.el b/test/src/treesit-tests.el index eb6e85c3fd6..c995542a2ae 100644 --- a/test/src/treesit-tests.el +++ b/test/src/treesit-tests.el | |||
| @@ -331,7 +331,11 @@ | |||
| 331 | 'json)) | 331 | 'json)) |
| 332 | ;; `treesit-node-at'. | 332 | ;; `treesit-node-at'. |
| 333 | (should (equal (treesit-node-string | 333 | (should (equal (treesit-node-string |
| 334 | (treesit-node-at 1 2 'json)) | 334 | (treesit-node-at 1 'json)) |
| 335 | "(\"[\")")) | ||
| 336 | ;; `treesit-node-on' | ||
| 337 | (should (equal (treesit-node-string | ||
| 338 | (treesit-node-on 1 2 'json)) | ||
| 335 | "(\"[\")")) | 339 | "(\"[\")")) |
| 336 | ;; `treesit-buffer-root-node'. | 340 | ;; `treesit-buffer-root-node'. |
| 337 | (should (treesit-node-eq | 341 | (should (treesit-node-eq |