public static async Task <BlazorMonaco.Range> ExpandTagRange(BlazorMonaco.Range matchRange, TextModel model) { BlazorMonaco.Range newRange = new BlazorMonaco.Range() { StartColumn = matchRange.StartColumn, StartLineNumber = matchRange.StartLineNumber }; int tagCloseLine = matchRange.EndLineNumber; Position endPos = await getClosingPosition(model, matchRange.EndLineNumber, matchRange.EndColumn - 1); newRange.EndColumn = endPos.Column; newRange.EndLineNumber = endPos.LineNumber; return(newRange); //local non static recursive method async Task <Position> getClosingPosition(TextModel model, int lineNum, int colNum) { Position pos = new Position(); string line = await model.GetLineContent(lineNum); int tagCloseCol = line.IndexOf(">", colNum); if (tagCloseCol == -1) //not found { pos = await getClosingPosition(model, lineNum + 1, 0); } else { pos.Column = tagCloseCol + 2; pos.LineNumber = lineNum; } return(pos); } }