tree-sitter/lib
Riley Bruins 6850df969d fix(query): prevent cycles when analyzing hidden children
**Problem:** `query.c` compares the current analysis state with the
previous analysis state to see if they are equal, so that it can return
early if so. This prevents redundant work. However, the comparison
function here differs from the one used for sorted insertion/lookup in
that it does not check any state data other than the child index. This
is problematic because it leads to infinite analysis when hidden nodes
have cycles.

**Solution:** Remove the custom comparison function, and apply the
insertion/lookup comparison function in place of it.

**NOTE:** This commit also changes the comparison function slightly, so
that some comparisons are reordered. Namely, for performance, it returns
early if the lhs depth is less than the rhs depth. Is this acceptable?
Tests still pass and nothing hangs in my testing, but it still seems
sketchy. Returning early if the lhs depth is greater than the rhs depth
does seem to make query analysis hang, weirdly enough... Keeping the
depth checks at the end of the loop also works, but it introduces a
noticeable performance regression (for queries that otherwise wouldn't
have had analysis cycles, of course).
2025-07-30 00:41:01 -04:00
..
binding_rust fix(rust): prevent overflow in error message calculation 2025-07-22 09:51:28 +02:00
binding_web chore(web): fix indentation in type files 2025-07-14 12:50:04 +02:00
include/tree_sitter fix(lib): remove duplicate TSLanguageMetadata typedef (#4268) 2025-03-06 14:14:25 -08:00
src fix(query): prevent cycles when analyzing hidden children 2025-07-30 00:41:01 -04:00
.ccls rust: Change QueryCursor::captures to expose the full match 2019-10-03 12:45:58 -07:00
Cargo.toml feat(rust): Add direct links to documentation 2025-07-22 18:36:08 -04:00
CMakeLists.txt fix(build): pkgconfig and use of GNUInstallDirs (#4319) 2025-05-31 11:45:35 +02:00
README.md docs: update badges; fix markdown lint complains 2023-04-16 23:39:08 +03:00
tree-sitter.pc.in build(lib): build using cmake 2024-09-07 18:38:05 -04:00

Subdirectories

  • src - C source code for the Tree-sitter library
  • include - C headers for the Tree-sitter library
  • binding_rust - Rust bindings to the Tree-sitter library
  • binding_web - JavaScript bindings to the Tree-sitter library, using WebAssembly