diff --git a/src/vs/editor/common/viewLayout/viewLineRenderer.ts b/src/vs/editor/common/viewLayout/viewLineRenderer.ts index 05bf9c93c5c..70666540426 100644 --- a/src/vs/editor/common/viewLayout/viewLineRenderer.ts +++ b/src/vs/editor/common/viewLayout/viewLineRenderer.ts @@ -495,10 +495,14 @@ function _applyInlineDecorations(lineContent: string, len: number, tokens: ViewL } if (lineDecoration.endOffset + 1 <= tokenEndIndex) { + // This line decoration ends before this token ends lastResultEndIndex = lineDecoration.endOffset + 1; result[resultLen++] = new ViewLineToken(lastResultEndIndex, tokenType + ' ' + lineDecoration.className); lineDecorationIndex++; } else { + // This line decoration continues on to the next token + lastResultEndIndex = tokenEndIndex; + result[resultLen++] = new ViewLineToken(lastResultEndIndex, tokenType + ' ' + lineDecoration.className); break; } } diff --git a/src/vs/editor/test/common/viewLayout/viewLineParts.test.ts b/src/vs/editor/test/common/viewLayout/viewLineParts.test.ts index c275ff59a6d..c40b9f83ed9 100644 --- a/src/vs/editor/test/common/viewLayout/viewLineParts.test.ts +++ b/src/vs/editor/test/common/viewLayout/viewLineParts.test.ts @@ -100,6 +100,47 @@ suite('Editor ViewLayout - ViewLineParts', () => { assert.deepEqual(actual.output, expected); }); + test('issue #19207: Link in Monokai is not rendered correctly', () => { + + let lineContent = '\'let url = `http://***/_api/web/lists/GetByTitle(\\\'Teambuildingaanvragen\\\')/items`;\''; + + let actual = renderViewLine(new RenderLineInput( + true, + lineContent, + false, + 0, + [ + new ViewLineToken(49, 'mtk6'), + new ViewLineToken(51, 'mtk4'), + new ViewLineToken(72, 'mtk6'), + new ViewLineToken(74, 'mtk4'), + new ViewLineToken(84, 'mtk6'), + ], + [ + new Decoration(13, 51, 'detected-link', false) + ], + 4, + 10, + -1, + 'none', + false + )); + + let expected = [ + '', + '\'let url = `', + 'http://***/_api/web/lists/GetByTitle(', + '\\', + '\'', + 'Teambuildingaanvragen', + '\\\'', + ')/items`;\'', + '' + ].join(''); + + assert.deepEqual(actual.output, expected); + }); + test('createLineParts simple', () => { testCreateLineParts( false,