public BracketSearchResult SearchBracket(TextDocument document, int offset) { BracketSearchResult result; if (offset > 0) { var charAt = document.GetCharAt(offset - 1); var num = "([{".IndexOf(charAt); var num2 = -1; if (num > -1) { num2 = SearchBracketForward(document, offset, "([{"[num], ")]}"[num]); } num = ")]}".IndexOf(charAt); if (num > -1) { num2 = SearchBracketBackward(document, offset - 2, "([{"[num], ")]}"[num]); } if (num2 > -1) { result = new BracketSearchResult(Math.Min(offset - 1, num2), 1, Math.Max(offset - 1, num2), 1); return result; } } result = null; return result; }
public void SetHighlight(BracketSearchResult result) { if (_result != result) { _result = result; _textView.InvalidateLayer(Layer); } }