Fixes issue #19207: Link in Monokai is not rendered correctly

This commit is contained in:
Alex Dima
2017-01-24 15:25:27 +01:00
parent 0e7ffee956
commit 8ac4bfdbac
2 changed files with 45 additions and 0 deletions
@@ -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;
}
}
@@ -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 = [
'<span>',
'<span class="mtk6">\'let&nbsp;url&nbsp;=&nbsp;`</span>',
'<span class="mtk6 detected-link">http://***/_api/web/lists/GetByTitle(</span>',
'<span class="mtk4 detected-link">\\</span>',
'<span class="mtk4">\'</span>',
'<span class="mtk6">Teambuildingaanvragen</span>',
'<span class="mtk4">\\\'</span>',
'<span class="mtk6">)/items`;\'</span>',
'</span>'
].join('');
assert.deepEqual(actual.output, expected);
});
test('createLineParts simple', () => {
testCreateLineParts(
false,