Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 18 additions & 26 deletions res/queries/python/textobjects/cell.scm
Original file line number Diff line number Diff line change
@@ -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.
;; inherits: python
;; extends

; vanilla script, without separator
(module
.
(_) @_nonseparator @_start @_end
.
(_)* @_nonseparator @_end
(_)+ @cell
.
(#match-cell-content? @_nonseparator)
(#make-range! "cell" @_start @_end)
(#match-cell-content? @cell)
)

; first cell, follow a separator
(module
.
(_) @_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) @_cellseparator
(#match-cell-content? @_nonseparator)
(#match-cell-content? @cell)
(#match-percent-separator? @_cellseparator)
(#make-range! "cell" @_start @_end)
)

; cell between two separator
(module
(comment) @_cellseparator @_start
.
(_)+ @_nonseparator @_end
.
(comment) @_cellseparator
(#match-cell-content? @_nonseparator)
(#match-percent-separator? @_cellseparator)
(#make-range! "cell" @_start @_end)
(comment) @_cellseparator @cell
(_)* @_cellcontent @cell
(comment) @_cellseparator
(#match-cell-content? @_cellcontent)
(#match-percent-separator? @_cellseparator)
Comment on lines +25 to +29
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
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.
)


; latest cell after separator
(module
(comment) @_cellseparator @_start
.
(_) @_nonseparator @_end
(_)* @_nonseparator @_end
.
(#match-cell-content? @_nonseparator)
(#match-percent-separator? @_cellseparator)
(#make-range! "cell" @_start @_end)
(
(comment) @_cellseparator @cell
(_)* @_cellcontent @cell
.
(#match-cell-content? @_cellcontent)
(#match-percent-separator? @_cellseparator)
)
Comment on lines +35 to +41
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.
)


26 changes: 8 additions & 18 deletions res/queries/python/textobjects/cellcontent.scm
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,40 @@
; vanilla script, without separator
(module
.
(_) @_nonseparator @_start @_end
(_)+ @cellcontent
.
(_)* @_nonseparator @_end
.
(#match-cell-content? @_nonseparator)
(#make-range! "cellcontent" @_start @_end)
(#match-cell-content? @cellcontent)
)

; first cell, follow a separator
(module
.
(_) @_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.
.
(comment) @_cellseparator
(#match-cell-content? @_nonseparator)
(#match-cell-content? @cellcontent)
(#match-percent-separator? @_cellseparator)
(#make-range! "cellcontent" @_start @_end)
)

; cell between two separator
(module
(comment) @_cellseparator
.
(_) @_nonseparator @_start @_end
(_)* @_nonseparator @_end
(_)+ @cellcontent
.
(comment) @_cellseparator
(#match-cell-content? @_nonseparator)
(#match-cell-content? @cellcontent)
(#match-percent-separator? @_cellseparator)
(#make-range! "cellcontent" @_start @_end)
)


; latest cell after separator
(module
(comment) @_cellseparator
.
(_) @_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.
.
(#match-cell-content? @_nonseparator)
(#match-cell-content? @cellcontent)
(#match-percent-separator? @_cellseparator)
(#make-range! "cellcontent" @_start @_end)
)

Loading