Пример #1
0
        void CreateFormattedLineSource(double viewportWidthOverride)
        {
            lastFormattedLineSourceViewportWidth = viewportWidthOverride;
            var    wordWrapStyle  = Options.WordWrapStyle();
            bool   isWordWrap     = (wordWrapStyle & WordWrapStyles.WordWrap) != 0;
            bool   isAutoIndent   = isWordWrap && (wordWrapStyle & WordWrapStyles.AutoIndent) != 0;
            double wordWrapWidth  = isWordWrap ? viewportWidthOverride : 0;
            var    maxAutoIndent  = isAutoIndent ? viewportWidthOverride / 4 : 0;
            bool   useDisplayMode = TextOptions.GetTextFormattingMode(this) == TextFormattingMode.Display;
            var    classifier     = Options.IsColorizationEnabled() ? aggregateClassifier : NullClassifier.Instance;

            int tabSize = Options.GetTabSize();

            tabSize = Math.Max(1, tabSize);
            tabSize = Math.Min(60, tabSize);

            // This value is what VS uses, see: https://msdn.microsoft.com/en-us/library/microsoft.visualstudio.text.formatting.iformattedlinesource.baseindentation.aspx
            //	"This is generally a small value like 2.0, so that some characters (such as an italic
            //	 slash) will not be clipped by the left edge of the view."
            const double baseIndent = 2.0;

            (FormattedLineSource as IDisposable)?.Dispose();
            FormattedLineSource = formattedTextSourceFactoryService.Create(
                TextSnapshot,
                VisualSnapshot,
                tabSize,
                baseIndent,
                wordWrapWidth,
                maxAutoIndent,
                useDisplayMode,
                classifier,
                textAndAdornmentSequencer,
                classificationFormatMap,
                (wordWrapStyle & (WordWrapStyles.WordWrap | WordWrapStyles.VisibleGlyphs)) == (WordWrapStyles.WordWrap | WordWrapStyles.VisibleGlyphs));
        }