Skip to content

Commit

Permalink
Fixes #11485: Don't set whitespace width if a line contains foreign e…
Browse files Browse the repository at this point in the history
…lements
  • Loading branch information
alexdima committed Jul 5, 2017
1 parent bef3bfd commit c6f8a5d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/vs/editor/common/viewLayout/viewLineRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ function _renderLine(input: ResolvedRenderLineInput): RenderLineOutput {
}

characterMapping.setPartLength(partIndex, partContentCnt);
if (fontIsMonospace) {
if (fontIsMonospace || containsForeignElements) {
out += `<span class="${partType}">${partContent}</span>`;
} else {
out += `<span class="${partType}" style="width:${spaceWidth * partContentCnt}px">${partContent}</span>`;
Expand Down
29 changes: 29 additions & 0 deletions src/vs/editor/test/common/viewLayout/viewLineRenderer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,35 @@ suite('viewLineRenderer.renderLine 2', () => {
].join(''));
});

test('issue #11485: Visible whitespace conflicts with before decorator attachment', () => {

let lineContent = '\tbla';

let actual = renderViewLine(new RenderLineInput(
false,
lineContent,
false,
0,
[createPart(4, 3)],
[new LineDecoration(1, 2, 'before', true)],
4,
10,
-1,
'all',
false,
true
));

let expected = [
'<span>',
'<span class="vs-whitespace before">&rarr;&nbsp;&nbsp;&nbsp;</span>',
'<span class="mtk3">bla</span>',
'</span>'
].join('');

assert.deepEqual(actual.html, expected);
});

function createTestGetColumnOfLinePartOffset(lineContent: string, tabSize: number, parts: ViewLineToken[], expectedPartLengths: number[]): (partIndex: number, partLength: number, offset: number, expected: number) => void {
let renderLineOutput = renderViewLine(new RenderLineInput(
false,
Expand Down

0 comments on commit c6f8a5d

Please sign in to comment.