From 4acd587bc02db39ae91c85184dc714708c764450 Mon Sep 17 00:00:00 2001 From: Patrick Plenefisch Date: Wed, 29 Sep 2021 03:12:23 -0400 Subject: [PATCH] Don't ignore the indent settings in advanced wrapping mode Fixes #132220 Fixes #120844 This still works in one pass by using negative text-indent with matching padding to generate a CSS-based hanging indent that we can measure. This could be upgraded to the `hanging` modifier in the far future. --- .../browser/view/domLineBreaksComputer.ts | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/vs/editor/browser/view/domLineBreaksComputer.ts b/src/vs/editor/browser/view/domLineBreaksComputer.ts index 91c216a6bf8..0d8f1683bff 100644 --- a/src/vs/editor/browser/view/domLineBreaksComputer.ts +++ b/src/vs/editor/browser/view/domLineBreaksComputer.ts @@ -69,12 +69,9 @@ function createLineBreaks(requests: string[], fontInfo: FontInfo, tabSize: numbe } const overallWidth = Math.round(firstLineBreakColumn * fontInfo.typicalHalfwidthCharacterWidth); - - // Cannot respect WrappingIndent.Indent and WrappingIndent.DeepIndent because that would require - // two dom layouts, in order to first set the width of the first line, and then set the width of the wrapped lines - if (wrappingIndent === WrappingIndent.Indent || wrappingIndent === WrappingIndent.DeepIndent) { - wrappingIndent = WrappingIndent.Same; - } + const additionalIndent = (wrappingIndent === WrappingIndent.DeepIndent ? 2 : wrappingIndent === WrappingIndent.Indent ? 1 : 0); + const additionalIndentSize = Math.round(tabSize * additionalIndent); + const additionalIndentLength = Math.ceil(fontInfo.spaceWidth * additionalIndentSize); const containerDomNode = document.createElement('div'); Configuration.applyFontInfoSlow(containerDomNode, fontInfo); @@ -123,7 +120,7 @@ function createLineBreaks(requests: string[], fontInfo: FontInfo, tabSize: numbe } const renderLineContent = lineContent.substr(firstNonWhitespaceIndex); - const tmp = renderLine(renderLineContent, wrappedTextIndentLength, tabSize, width, sb); + const tmp = renderLine(renderLineContent, wrappedTextIndentLength, tabSize, width, sb, additionalIndentLength); firstNonWhitespaceIndices[i] = firstNonWhitespaceIndex; wrappedTextIndentLengths[i] = wrappedTextIndentLength; renderLineContents[i] = renderLineContent; @@ -152,7 +149,7 @@ function createLineBreaks(requests: string[], fontInfo: FontInfo, tabSize: numbe } const firstNonWhitespaceIndex = firstNonWhitespaceIndices[i]; - const wrappedTextIndentLength = wrappedTextIndentLengths[i]; + const wrappedTextIndentLength = wrappedTextIndentLengths[i] + additionalIndentSize; const visibleColumns = allVisibleColumns[i]; const breakOffsetsVisibleColumn: number[] = []; @@ -189,8 +186,18 @@ const enum Constants { SPAN_MODULO_LIMIT = 16384 } -function renderLine(lineContent: string, initialVisibleColumn: number, tabSize: number, width: number, sb: IStringBuilder): [number[], number[]] { - sb.appendASCIIString('
'); // if (containsRTL) {