To find all text ranges tagged with a specific indicator, use Indicator.Start(position) and Indicator.End(position).
Important Logic Note: These methods can be counter-intuitive. Depending on whether the starting position is currently tagged with the indicator, they might return the start/end of a filled range or the start/end of an empty range.
To reliably iterate only through filled ranges, combine these methods with Scintilla.IndicatorAllOnFor(position). This method returns a bitmap where each bit corresponds to an indicator index. You can check if a specific indicator is present by performing a bitwise AND with a flag created via (1 << indicator.Index).
var textLength = scintilla.TextLength;
var indicator = scintilla.Indicators[8];
var bitmapFlag = (1 << indicator.Index);
var startPos = 0;
var endPos = 0;
do
{
startPos = indicator.Start(endPos);
endPos = indicator.End(startPos);
// Check if the range is actually filled with our specific indicator
var bitmap = scintilla.IndicatorAllOnFor(startPos);
var filled = ((bitmapFlag & bitmap) == bitmapFlag);
if (filled)
{
// Process the range
Debug.WriteLine(scintilla.GetTextRange(startPos, (endPos - startPos)));
}
} while (endPos != 0 && endPos < textLength);