mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
Fixes #22832: Consider fullwidth characters when rendering tabs
This commit is contained in:
parent
1d4ace9ee0
commit
c15001e11d
|
@ -450,6 +450,8 @@ function _applyRenderWhitespace(lineContent: string, len: number, tokens: LinePa
|
|||
const chCode = lineContent.charCodeAt(charIndex);
|
||||
if (chCode === CharCode.Tab) {
|
||||
tmpIndent = tabSize;
|
||||
} else if (strings.isFullWidthCharacter(chCode)) {
|
||||
tmpIndent += 2;
|
||||
} else {
|
||||
tmpIndent++;
|
||||
}
|
||||
|
@ -501,6 +503,8 @@ function _applyRenderWhitespace(lineContent: string, len: number, tokens: LinePa
|
|||
|
||||
if (chCode === CharCode.Tab) {
|
||||
tmpIndent = tabSize;
|
||||
} else if (strings.isFullWidthCharacter(chCode)) {
|
||||
tmpIndent += 2;
|
||||
} else {
|
||||
tmpIndent++;
|
||||
}
|
||||
|
@ -637,6 +641,7 @@ function _renderLine(input: ResolvedRenderLineInput, sb: IStringBuilder): Render
|
|||
_tabsCharDelta += insertSpacesCount - 1;
|
||||
partContentCnt += insertSpacesCount;
|
||||
} else {
|
||||
// must be CharCode.Space
|
||||
partContentCnt++;
|
||||
}
|
||||
}
|
||||
|
@ -735,6 +740,9 @@ function _renderLine(input: ResolvedRenderLineInput, sb: IStringBuilder): Render
|
|||
break;
|
||||
|
||||
default:
|
||||
if (strings.isFullWidthCharacter(charCode)) {
|
||||
tabsCharDelta++;
|
||||
}
|
||||
if (renderControlCharacters && charCode < 32) {
|
||||
sb.write1(9216 + charCode);
|
||||
partContentCnt++;
|
||||
|
|
|
@ -1197,6 +1197,64 @@ suite('viewLineRenderer.renderLine 2', () => {
|
|||
assert.deepEqual(actual.html, expected);
|
||||
});
|
||||
|
||||
test('issue #22832: Consider fullwidth characters when rendering tabs', () => {
|
||||
|
||||
let actual = renderViewLine(new RenderLineInput(
|
||||
true,
|
||||
'asd = "擦"\t\t#asd',
|
||||
false,
|
||||
0,
|
||||
createViewLineTokens([createPart(15, 3)]),
|
||||
[],
|
||||
4,
|
||||
10,
|
||||
10000,
|
||||
'none',
|
||||
false,
|
||||
false
|
||||
));
|
||||
|
||||
let expected = [
|
||||
'<span>',
|
||||
'<span class="mtk3">asd\u00a0=\u00a0"擦"\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0#asd</span>',
|
||||
'</span>'
|
||||
].join('');
|
||||
|
||||
assert.deepEqual(actual.html, expected);
|
||||
});
|
||||
|
||||
test('issue #22832: Consider fullwidth characters when rendering tabs (render whitespace)', () => {
|
||||
|
||||
let actual = renderViewLine(new RenderLineInput(
|
||||
true,
|
||||
'asd = "擦"\t\t#asd',
|
||||
false,
|
||||
0,
|
||||
createViewLineTokens([createPart(15, 3)]),
|
||||
[],
|
||||
4,
|
||||
10,
|
||||
10000,
|
||||
'all',
|
||||
false,
|
||||
false
|
||||
));
|
||||
|
||||
let expected = [
|
||||
'<span>',
|
||||
'<span class="mtk3">asd</span>',
|
||||
'<span class="vs-whitespace">\u00b7</span>',
|
||||
'<span class="mtk3">=</span>',
|
||||
'<span class="vs-whitespace">\u00b7</span>',
|
||||
'<span class="mtk3">"擦"</span>',
|
||||
'<span class="vs-whitespace">\u2192\u00a0\u2192\u00a0\u00a0\u00a0</span>',
|
||||
'<span class="mtk3">#asd</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,
|
||||
|
|
Loading…
Reference in a new issue