Skip to content

Conversation

@AbaoFromCUG
Copy link
Collaborator

Copilot AI review requested due to automatic review settings January 7, 2026 09:57
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes TreeSitter query files by removing deprecated make-range! directives and adopting quantified captures, a feature supported in newer versions of nvim-treesitter-textobjects (as referenced in PR #612). The changes simplify query patterns by using native TreeSitter quantifiers (+, *) instead of manually constructing ranges.

Key changes:

  • Replaced make-range! directive patterns with quantified capture syntax (+ and * quantifiers)
  • Simplified query patterns by directly capturing node sequences instead of defining start/end ranges
  • Updated example file by removing cell separator comments

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.

File Description
res/queries/python/textobjects/cellcontent.scm Converted from make-range! to quantified captures using (_)+ and _+ patterns for matching cell content
res/queries/python/textobjects/cell.scm Converted from make-range! to quantified captures, including restructured patterns for cells between separators
example/main.ju.py Removed Jupyter cell separator comments and content, simplifying the example file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +35 to +41
(
(comment) @_cellseparator @cell
(_)* @_cellcontent @cell
.
(#match-cell-content? @_cellcontent)
(#match-percent-separator? @_cellseparator)
)
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the "cell between two separator" pattern, this pattern applies #match-cell-content? to @_cellcontent which uses the * quantifier and could match zero nodes. The predicate should likely be applied to @cell or the pattern needs adjustment to ensure content nodes exist. Also, the extra parentheses grouping on lines 35-41 is inconsistent with other patterns in the file and may not be necessary.

Copilot uses AI. Check for mistakes.
@@ -1,52 +1,44 @@

Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file now starts with an unnecessary blank line. For consistency with other query files in the codebase, this blank line should be removed.

Copilot uses AI. Check for mistakes.
(_) @_nonseparator @_start @_end
.
(_)* @_nonseparator @_end
_+ @cellcontent
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent wildcard quantifier syntax: This pattern uses _+ while other patterns in the file use (_)+. In TreeSitter query syntax, _ is a wildcard that matches any single node, and quantifiers should be applied to parenthesized expressions. The correct syntax should be (_)+ to match one or more nodes of any type, consistent with lines 7 and 26.

Copilot uses AI. Check for mistakes.
.
(_) @_nonseparator @_start @_end
(_)* @_nonseparator @_end
_+ @cellcontent
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent wildcard quantifier syntax: This pattern uses _+ while other patterns in the file use (_)+. In TreeSitter query syntax, _ is a wildcard that matches any single node, and quantifiers should be applied to parenthesized expressions. The correct syntax should be (_)+ to match one or more nodes of any type, consistent with lines 7 and 26.

Copilot uses AI. Check for mistakes.
(_) @_nonseparator @_start @_end
.
(_)* @_nonseparator @_end
_+ @cell
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent wildcard quantifier syntax: This pattern uses _+ while line 8 uses (_)+. In TreeSitter query syntax, _ is a wildcard that matches any single node, and quantifiers should be applied to parenthesized expressions. The correct syntax should be (_)+ to match one or more nodes of any type, consistent with line 8.

Suggested change
_+ @cell
(_)+ @cell

Copilot uses AI. Check for mistakes.
Comment on lines +25 to +29
(comment) @_cellseparator @cell
(_)* @_cellcontent @cell
(comment) @_cellseparator
(#match-cell-content? @_cellcontent)
(#match-percent-separator? @_cellseparator)
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation in this query pattern is inconsistent with the rest of the file. Lines 25-29 use 4 spaces of indentation, while other patterns in the file (lines 6-11, 14-21, 34-42) use 2 spaces. This should be adjusted to 2 spaces for consistency.

Suggested change
(comment) @_cellseparator @cell
(_)* @_cellcontent @cell
(comment) @_cellseparator
(#match-cell-content? @_cellcontent)
(#match-percent-separator? @_cellseparator)
(comment) @_cellseparator @cell
(_)* @_cellcontent @cell
(comment) @_cellseparator
(#match-cell-content? @_cellcontent)
(#match-percent-separator? @_cellseparator)

Copilot uses AI. Check for mistakes.
Comment on lines +25 to +29
(comment) @_cellseparator @cell
(_)* @_cellcontent @cell
(comment) @_cellseparator
(#match-cell-content? @_cellcontent)
(#match-percent-separator? @_cellseparator)
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pattern change appears to alter the semantic meaning. Previously, this pattern matched the separator followed by content nodes, creating a range from the separator to the last content node. Now, it captures both the separator and content nodes together as @cell. However, the predicate #match-cell-content? is still applied to @_cellcontent instead of @cell, which may not work as intended since @_cellcontent uses the * quantifier and could match zero nodes. Consider whether the predicate should be applied to @cell or if the pattern needs adjustment.

Copilot uses AI. Check for mistakes.
@AbaoFromCUG AbaoFromCUG added the enhancement New feature or request label Jan 7, 2026
@AbaoFromCUG AbaoFromCUG merged commit e17b2a7 into master Jan 7, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Not compatible with nvim-treesitter main branch

2 participants