/// <summary>Creates a tag provider for the specified view and buffer.</summary>
        /// <returns>The <see cref="T:Microsoft.VisualStudio.Text.Tagging.ITagAggregator`1" /> of the correct type for <paramref name="textView" />.</returns>
        /// <param name="textView">The <see cref="T:Microsoft.VisualStudio.Text.Editor.ITextView" />.</param>
        /// <param name="buffer">The <see cref="T:Microsoft.VisualStudio.Text.ITextBuffer" />.</param>
        /// <typeparam name="T">The type of the tag.</typeparam>
        public ITagger <T> CreateTagger <T>(ITextView textView, ITextBuffer buffer) where T : ITag
        {
            string filePath = null;

            if (buffer.Properties.TryGetProperty(typeof(ITextDocument), out ITextDocument docProperty))
            {
                filePath = docProperty.FilePath;
            }
            var tagger = new Z80TestViewTagger(buffer, textView, filePath);

            return(tagger as ITagger <T>);
        }
        private void SourceBufferOnPostChanged(object sender, EventArgs eventArgs)
        {
            if (_fakeEdit)
            {
                return;
            }

            _fakeEdit = true;
            try
            {
                var(firstLine, lastLine) = Z80TestViewTagger.GetViewPortLines(FilePath);
                if (firstLine < 0)
                {
                    return;
                }

                var edit = SourceBuffer.CreateEdit();
                for (var i = firstLine; i <= lastLine; i++)
                {
                    var modeLine = SourceBuffer.CurrentSnapshot.GetLineFromLineNumber(i);
                    var pos      = modeLine.End.Position;
                    edit.Insert(pos, " ");
                }
                edit.Apply();
                edit = SourceBuffer.CreateEdit();
                for (var i = firstLine; i <= lastLine; i++)
                {
                    var modeLine = SourceBuffer.CurrentSnapshot.GetLineFromLineNumber(i);
                    var pos      = modeLine.End.Position;
                    edit.Delete(new Span(pos - 1, 1));
                }
                edit.Apply();
            }
            finally
            {
                _fakeEdit = false;
            }
        }