diff options
| author | Yuan Fu | 2023-09-11 12:47:32 -0700 |
|---|---|---|
| committer | Yuan Fu | 2023-09-11 12:50:31 -0700 |
| commit | 33ee3e588fd9744714f1c0ab64de75a61db5eaca (patch) | |
| tree | 8d12b81e9a6ef27f3af59e68ece33aa6d064d438 /src | |
| parent | d11d81dfcc6b50a8e889789e2d4696af1a544f7f (diff) | |
| download | emacs-33ee3e588fd9744714f1c0ab64de75a61db5eaca.tar.gz emacs-33ee3e588fd9744714f1c0ab64de75a61db5eaca.zip | |
Fix regression of treesit_cursor_helper_1
* src/treesit.c (treesit_cursor_helper_1)
(treesit_cursor_first_child_for_byte): Use
ts_tree_cursor_goto_first_child_for_byte first, and
ts_tree_cursor_goto_first_child second.
Diffstat (limited to 'src')
| -rw-r--r-- | src/treesit.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/treesit.c b/src/treesit.c index cb2113b3faf..8419452d54a 100644 --- a/src/treesit.c +++ b/src/treesit.c | |||
| @@ -2160,7 +2160,10 @@ return nil. */) | |||
| 2160 | static bool treesit_cursor_first_child_for_byte | 2160 | static bool treesit_cursor_first_child_for_byte |
| 2161 | (TSTreeCursor *cursor, ptrdiff_t pos, bool named) | 2161 | (TSTreeCursor *cursor, ptrdiff_t pos, bool named) |
| 2162 | { | 2162 | { |
| 2163 | if (!ts_tree_cursor_goto_first_child (cursor)) | 2163 | /* ts_tree_cursor_goto_first_child_for_byte is significantly faster, |
| 2164 | so despite it having problems, we try it first. */ | ||
| 2165 | if (ts_tree_cursor_goto_first_child_for_byte (cursor, pos) == -1 | ||
| 2166 | && !ts_tree_cursor_goto_first_child (cursor)) | ||
| 2164 | return false; | 2167 | return false; |
| 2165 | 2168 | ||
| 2166 | TSNode node = ts_tree_cursor_current_node (cursor); | 2169 | TSNode node = ts_tree_cursor_current_node (cursor); |
| @@ -2890,7 +2893,11 @@ treesit_cursor_helper_1 (TSTreeCursor *cursor, TSNode *target, | |||
| 2890 | if (ts_node_eq (cursor_node, *target)) | 2893 | if (ts_node_eq (cursor_node, *target)) |
| 2891 | return true; | 2894 | return true; |
| 2892 | 2895 | ||
| 2893 | if (ts_tree_cursor_goto_first_child_for_byte (cursor, start_pos) == -1) | 2896 | /* ts_tree_cursor_goto_first_child_for_byte is significantly faster, |
| 2897 | so despite it having problems (see bug#60127), we try it | ||
| 2898 | first. */ | ||
| 2899 | if (ts_tree_cursor_goto_first_child_for_byte (cursor, start_pos) == -1 | ||
| 2900 | && !ts_tree_cursor_goto_first_child (cursor)) | ||
| 2894 | return false; | 2901 | return false; |
| 2895 | 2902 | ||
| 2896 | /* Go through each sibling that could contain TARGET. Because of | 2903 | /* Go through each sibling that could contain TARGET. Because of |