That sounds reasonable. The logic should be similar to the `matchbrackets.js` addon. @marijnh?