Skip to content

fix(diffr): remove fold query conflicts in bundled queries - #1084

Merged
sidkmenon merged 8 commits into
mainfrom
diffr/fold-query-contract
Oct 10, 2026
Merged

sidkmenon merged 8 commits into
mainfrom
diffr/fold-query-contract

Conversation

@sidkmenon

@sidkmenon sidkmenon commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Fix an issue some users were hitting w/ diffr's builtin queries clashing.

I tried, at first, to set up a deterministic testing harness but seems a bit hard to do bc it depends on tree-sitter behavior + how it actually responds to the queries / constructing a model there.

it's too easy to represent bad/illegal state with the query architecture here. a better solution might be:

  • diffr has a set of tree-sitter queries which define what "foldable" is in the ast
  • separately, 'shape' plugins can then fold regions, aggregate foldable areas, or change this stuff as they want.
  • finally, diffr should have some logic to collapse the tree as heavily as possible given the set of what's changed + what's collapsed already.

that's a bigger change so this is a band-aid in the meantime.

https://claude.ai/code/session_01DUhupf8DSVYZ4Cif39LxWd

A body run starting at the first statement gave that statement two folds
when it also folds itself (a list, pipeline, if or loop).

Agent-Session: 4fa14265-1d4d-4ea8-b2f0-abdee40eb54d
Agent-Session: 01a122cb-3cae-7ac3-b791-09a8faa89ffd
Agent-Session: 01a12325-f61d-73b2-846e-9886a80037d5
Agent-Session: 01a12327-e4f9-7652-bc41-f37bec9965f4
Agent-Session: 8881e3f3-a916-4405-9706-bb6e3a2f193d
A body run starting at the first statement gave that statement two folds
when it also folds itself. Dropping the else relevant region shifts fold
ids in one golden; its output is unchanged.

Agent-Session: 4fa14265-1d4d-4ea8-b2f0-abdee40eb54d
Agent-Session: 01a122cb-3cae-7ac3-b791-09a8faa89ffd
Agent-Session: 01a12325-f61d-73b2-846e-9886a80037d5
Agent-Session: 01a12327-e4f9-7652-bc41-f37bec9965f4
Agent-Session: 8881e3f3-a916-4405-9706-bb6e3a2f193d
…line

Both branches of the label alternation matched `outer: for {`, folding
one block with two indents.

Agent-Session: 4fa14265-1d4d-4ea8-b2f0-abdee40eb54d
Agent-Session: 01a122cb-3cae-7ac3-b791-09a8faa89ffd
Agent-Session: 01a12325-f61d-73b2-846e-9886a80037d5
Agent-Session: 01a12327-e4f9-7652-bc41-f37bec9965f4
Agent-Session: 8881e3f3-a916-4405-9706-bb6e3a2f193d
The condition owned it, and context also folds a condition that is a
call.

Agent-Session: 4fa14265-1d4d-4ea8-b2f0-abdee40eb54d
Agent-Session: 01a122cb-3cae-7ac3-b791-09a8faa89ffd
Agent-Session: 01a12325-f61d-73b2-846e-9886a80037d5
Agent-Session: 01a12327-e4f9-7652-bc41-f37bec9965f4
Agent-Session: 8881e3f3-a916-4405-9706-bb6e3a2f193d
The open-ended and body patterns folded one sequence with different
indents.

Agent-Session: 4fa14265-1d4d-4ea8-b2f0-abdee40eb54d
Agent-Session: 01a122cb-3cae-7ac3-b791-09a8faa89ffd
Agent-Session: 01a12325-f61d-73b2-846e-9886a80037d5
Agent-Session: 01a12327-e4f9-7652-bc41-f37bec9965f4
Agent-Session: 8881e3f3-a916-4405-9706-bb6e3a2f193d
An unanchored "(" could match more than one child.

Agent-Session: 4fa14265-1d4d-4ea8-b2f0-abdee40eb54d
Agent-Session: 01a122cb-3cae-7ac3-b791-09a8faa89ffd
Agent-Session: 01a12325-f61d-73b2-846e-9886a80037d5
Agent-Session: 01a12327-e4f9-7652-bc41-f37bec9965f4
Agent-Session: 8881e3f3-a916-4405-9706-bb6e3a2f193d
The same folds, written so each pattern's captures are determined by its
owner.

Agent-Session: 4fa14265-1d4d-4ea8-b2f0-abdee40eb54d
Agent-Session: 01a122cb-3cae-7ac3-b791-09a8faa89ffd
Agent-Session: 01a12325-f61d-73b2-846e-9886a80037d5
Agent-Session: 01a12327-e4f9-7652-bc41-f37bec9965f4
Agent-Session: 8881e3f3-a916-4405-9706-bb6e3a2f193d
Agent-Session: 4fa14265-1d4d-4ea8-b2f0-abdee40eb54d
Agent-Session: 01a122cb-3cae-7ac3-b791-09a8faa89ffd
Agent-Session: 01a12325-f61d-73b2-846e-9886a80037d5
Agent-Session: 01a12327-e4f9-7652-bc41-f37bec9965f4
Agent-Session: 8881e3f3-a916-4405-9706-bb6e3a2f193d
@sidkmenon
sidkmenon merged commit ffaa78e into main Oct 10, 2026
10 checks passed
@sidkmenon
sidkmenon deleted the diffr/fold-query-contract branch October 10, 2026 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants