fix(playground): update query API

(cherry picked from commit a7d8c0cbb2)
This commit is contained in:
kevin-hua-kraken 2025-12-23 17:36:40 +09:00 committed by Christian Clason
parent c4f81931e6
commit 34602af22c

View file

@ -61,7 +61,7 @@ function initializeCustomSelect({ initialValue = null, addListeners = false }) {
}
window.initializePlayground = async (opts) => {
const { Parser, Language } = window.TreeSitter;
const { Parser, Language, Query } = window.TreeSitter;
const { local } = opts;
if (local) {
@ -357,11 +357,10 @@ window.initializePlayground = async (opts) => {
marks.forEach((m) => m.clear());
if (tree && query) {
const captures = query.captures(
tree.rootNode,
{ row: startRow, column: 0 },
{ row: endRow, column: 0 },
);
const captures = query.captures(tree.rootNode, {
startPosition: { row: startRow, column: 0 },
endPosition: { row: endRow, column: 0 },
});
let lastNodeId;
for (const { name, node } of captures) {
if (node.id === lastNodeId) continue;
@ -410,7 +409,7 @@ window.initializePlayground = async (opts) => {
const queryText = queryEditor.getValue();
try {
query = parser.language.query(queryText);
query = new Query(parser.language, queryText);
let match;
let row = 0;