/// <summary>
        /// Creates an ElasticTabstopsFormatters for
        /// the provided configuration.
        /// </summary>
        public TextParagraphProperties Create(IFormattedLineSource formattedLineSource, TextFormattingRunProperties textProperties,
                                              IMappingSpan line, IMappingPoint lineStart, int lineSegment)
        {
            if (!AlwaysAlignedConfigurationService.Instance.GetConfiguration().Enabled)
            {
                return(new TextFormattingParagraphProperties(textProperties, formattedLineSource.ColumnWidth * formattedLineSource.TabSize));
            }

            IWpfTextView textView = _textBufferToViewMapService.GetViewByFormattedLineSource(formattedLineSource);

            //View is not initialized yet
            if (textView == null)
            {
                return(new TextFormattingParagraphProperties(textProperties, formattedLineSource.ColumnWidth * formattedLineSource.TabSize));
            }
            var manager = ElasticTabstopsSizeManager.Get(textView);

            ITextSnapshot textSnapshot = formattedLineSource.SourceTextSnapshot;
            ITextBuffer   textBuffer   = textSnapshot.TextBuffer;

            var normalizedspancoll        = line.GetSpans(textBuffer);
            ITextSnapshotLine currentLine = textSnapshot.GetLineFromPosition(normalizedspancoll.First().Start.Position);

            //Get tab offset calculated by ElasticTabstopsSizeManager
            double[] tabOffsets = manager.GetTabOffsets(currentLine);

            return(new ElasticTabstopsFormatter(textProperties, formattedLineSource, tabOffsets));
        }
            void InstanceConfigurationSaved(object sender, ConfigurationSavedEventArgs e)
            {
                if (!e.HasChanges)
                {
                    return;
                }

                var tabStopsManager = ElasticTabstopsSizeManager.Get(_textView);

                tabStopsManager.InvalidateChanges();

                RefreshView();
            }
            private void OnBufferPostChanged(object sender, EventArgs e)
            {
                if (!AlwaysAlignedConfigurationService.Instance.Config.Enabled)
                {
                    return;
                }

                var tabStopsManager = ElasticTabstopsSizeManager.Get(_textView);

                if (tabStopsManager != null)
                {
                    tabStopsManager.InvalidateChanges(_lastChange);
                    RefreshView();
                }
            }
 public IWpfTextViewMargin CreateMargin(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin marginContainer)
 {
     ElasticTabstopsSizeManager.Create(wpfTextViewHost.TextView);
     return(new FakeWpfTextViewMargin(this, wpfTextViewHost.TextView));
 }