public void Draw(TextView textView, DrawingContext drawingContext)
        {
            if (textView.CaretIndex != -1)
            {
                var caretChar       = '\0';
                var behindCaretChar = '\0';

                if (textView.CaretIndex < textView.TextDocument.TextLength)
                {
                    caretChar = textView.TextDocument.GetCharAt(textView.CaretIndex);
                }

                if (textView.CaretIndex - 1 > 0 && textView.CaretIndex < textView.TextDocument.TextLength)
                {
                    behindCaretChar = textView.TextDocument.GetCharAt(textView.CaretIndex - 1);
                }

                if (caretChar.IsOpenBracketChar() && !caretChar.IsPunctuationChar())
                {
                    var closeOffset = textView.FindMatchingBracketForward(textView.CaretIndex, caretChar,
                                                                          caretChar.GetCloseBracketChar());

                    Highlight(drawingContext,
                              VisualLineGeometryBuilder.GetRectsForSegment(textView,
                                                                           new TextSegment {
                        StartOffset = textView.CaretIndex, EndOffset = textView.CaretIndex + 1
                    }));
                    Highlight(drawingContext,
                              VisualLineGeometryBuilder.GetRectsForSegment(textView,
                                                                           new TextSegment {
                        StartOffset = closeOffset, EndOffset = closeOffset + 1
                    }));
                }

                if (behindCaretChar.IsCloseBracketChar() && !behindCaretChar.IsPunctuationChar())
                {
                    var openOffset = textView.FindMatchingBracketBackward(textView.CaretIndex - 1, behindCaretChar,
                                                                          behindCaretChar.GetOpenBracketChar());

                    Highlight(drawingContext,
                              VisualLineGeometryBuilder.GetRectsForSegment(textView,
                                                                           new TextSegment {
                        StartOffset = textView.CaretIndex - 1, EndOffset = textView.CaretIndex
                    }));
                    Highlight(drawingContext,
                              VisualLineGeometryBuilder.GetRectsForSegment(textView,
                                                                           new TextSegment {
                        StartOffset = openOffset, EndOffset = openOffset + 1
                    }));
                }
            }
        }
        public void Draw(TextView textView, DrawingContext drawingContext)
		{
			if (textView.CaretIndex != -1)
			{
				var caretChar = '\0';
				var behindCaretChar = '\0';

				if (textView.CaretIndex < textView.TextDocument.TextLength)
				{
					caretChar = textView.TextDocument.GetCharAt(textView.CaretIndex);
				}

				if (textView.CaretIndex - 1 > 0 && textView.CaretIndex < textView.TextDocument.TextLength)
				{
					behindCaretChar = textView.TextDocument.GetCharAt(textView.CaretIndex - 1);
				}

				if (caretChar.IsOpenBracketChar() && !caretChar.IsPunctuationChar())
				{
					var closeOffset = textView.FindMatchingBracketForward(textView.CaretIndex, caretChar,
						caretChar.GetCloseBracketChar());

					Highlight(drawingContext,
						VisualLineGeometryBuilder.GetRectsForSegment(textView,
							new TextSegment {StartOffset = textView.CaretIndex, EndOffset = textView.CaretIndex + 1}));
					Highlight(drawingContext,
						VisualLineGeometryBuilder.GetRectsForSegment(textView,
							new TextSegment {StartOffset = closeOffset, EndOffset = closeOffset + 1}));
				}

				if (behindCaretChar.IsCloseBracketChar() && !behindCaretChar.IsPunctuationChar())
				{
					var openOffset = textView.FindMatchingBracketBackward(textView.CaretIndex - 1, behindCaretChar,
						behindCaretChar.GetOpenBracketChar());

					Highlight(drawingContext,
						VisualLineGeometryBuilder.GetRectsForSegment(textView,
							new TextSegment {StartOffset = textView.CaretIndex - 1, EndOffset = textView.CaretIndex}));
					Highlight(drawingContext,
						VisualLineGeometryBuilder.GetRectsForSegment(textView,
							new TextSegment {StartOffset = openOffset, EndOffset = openOffset + 1}));
				}
			}
		}