in playground/tree-sitter/concrete-syntax.js [518:553]
function attachCodeChangeListener() {
if (window.playground && window.playground.codeEditor) {
debugLog('Attaching code change listener to playground editor');
let debounceTimer;
window.playground.codeEditor.on('change', function() {
debugLog('Code editor change detected');
// Only re-execute if concrete syntax is active and has a pattern
const queryType = document.querySelector('input[name="query-type"]:checked');
if (queryType && queryType.value === 'concrete-syntax') {
debugLog('Concrete syntax is active, checking for pattern');
const concreteSyntaxEditor = getConcreteSyntaxEditor();
if (concreteSyntaxEditor) {
const pattern = concreteSyntaxEditor.getValue().trim();
if (pattern) {
debugLog('Pattern found, executing concrete syntax matching');
clearTimeout(debounceTimer);
debounceTimer = setTimeout(() => {
executeConcreteSyntaxPattern(pattern);
}, 500); // 500ms debounce for code changes
} else {
debugLog('No pattern found');
}
} else {
debugLog('No concrete syntax editor found');
}
} else {
debugLog('Concrete syntax not active');
}
});
return true; // Successfully attached
}
return false; // Failed to attach
}