I'm trying to retrieve the line number of a given string in the text displayed in the ace editor.
Iterate over all lines and check indexOf
function findFooLineNumbers(editor, foo) {
var lines = editor.session.doc.getAllLines()
var fooLineNumbers = []
for (var i = 0, l = lines.length; i < l; i++) {
if (lines[i].indexOf(foo) != -1)
fooLineNumbers.push(i)
}
return fooLineNumbers
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With