Fixes #2255: Do not reset tabsCharDelta
for each part
This commit is contained in:
parent
55b8bff54b
commit
c143e5aa92
|
@ -254,9 +254,9 @@ class InternalEditorOptionsHelper {
|
|||
experimentalScreenReader: (prevOpts.experimentalScreenReader !== newOpts.experimentalScreenReader),
|
||||
ariaLabel: (prevOpts.ariaLabel !== newOpts.ariaLabel),
|
||||
|
||||
lineNumbers: (prevOpts.lineNumbers !== newOpts.lineNumbers),
|
||||
selectOnLineNumbers: (prevOpts.selectOnLineNumbers !== newOpts.selectOnLineNumbers),
|
||||
glyphMargin: (prevOpts.glyphMargin !== newOpts.glyphMargin),
|
||||
lineNumbers: (prevOpts.lineNumbers !== newOpts.lineNumbers),
|
||||
selectOnLineNumbers: (prevOpts.selectOnLineNumbers !== newOpts.selectOnLineNumbers),
|
||||
glyphMargin: (prevOpts.glyphMargin !== newOpts.glyphMargin),
|
||||
revealHorizontalRightPadding: (prevOpts.revealHorizontalRightPadding !== newOpts.revealHorizontalRightPadding),
|
||||
roundedSelection: (prevOpts.roundedSelection !== newOpts.roundedSelection),
|
||||
theme: (prevOpts.theme !== newOpts.theme),
|
||||
|
@ -264,7 +264,7 @@ class InternalEditorOptionsHelper {
|
|||
scrollbar: (!this._scrollbarOptsEqual(prevOpts.scrollbar, newOpts.scrollbar)),
|
||||
overviewRulerLanes: (prevOpts.overviewRulerLanes !== newOpts.overviewRulerLanes),
|
||||
cursorBlinking: (prevOpts.cursorBlinking !== newOpts.cursorBlinking),
|
||||
cursorStyle: (prevOpts.cursorStyle !== newOpts.cursorStyle),
|
||||
cursorStyle: (prevOpts.cursorStyle !== newOpts.cursorStyle),
|
||||
fontLigatures: (prevOpts.fontLigatures !== newOpts.fontLigatures),
|
||||
hideCursorInOverviewRuler: (prevOpts.hideCursorInOverviewRuler !== newOpts.hideCursorInOverviewRuler),
|
||||
scrollBeyondLastLine: (prevOpts.scrollBeyondLastLine !== newOpts.scrollBeyondLastLine),
|
||||
|
@ -279,11 +279,11 @@ class InternalEditorOptionsHelper {
|
|||
forcedTokenizationBoundary: (prevOpts.forcedTokenizationBoundary !== newOpts.forcedTokenizationBoundary),
|
||||
|
||||
hover: (prevOpts.hover !== newOpts.hover),
|
||||
contextmenu: (prevOpts.contextmenu !== newOpts.contextmenu),
|
||||
contextmenu: (prevOpts.contextmenu !== newOpts.contextmenu),
|
||||
quickSuggestions: (prevOpts.quickSuggestions !== newOpts.quickSuggestions),
|
||||
quickSuggestionsDelay: (prevOpts.quickSuggestionsDelay !== newOpts.quickSuggestionsDelay),
|
||||
iconsInSuggestions: (prevOpts.iconsInSuggestions !== newOpts.iconsInSuggestions),
|
||||
autoClosingBrackets: (prevOpts.autoClosingBrackets !== newOpts.autoClosingBrackets),
|
||||
autoClosingBrackets: (prevOpts.autoClosingBrackets !== newOpts.autoClosingBrackets),
|
||||
formatOnType: (prevOpts.formatOnType !== newOpts.formatOnType),
|
||||
suggestOnTriggerCharacters: (prevOpts.suggestOnTriggerCharacters !== newOpts.suggestOnTriggerCharacters),
|
||||
selectionHighlight: (prevOpts.selectionHighlight !== newOpts.selectionHighlight),
|
||||
|
@ -291,12 +291,12 @@ class InternalEditorOptionsHelper {
|
|||
referenceInfos: (prevOpts.referenceInfos !== newOpts.referenceInfos),
|
||||
renderWhitespace: (prevOpts.renderWhitespace !== newOpts.renderWhitespace),
|
||||
|
||||
layoutInfo: (!EditorLayoutProvider.layoutEqual(prevOpts.layoutInfo, newOpts.layoutInfo)),
|
||||
layoutInfo: (!EditorLayoutProvider.layoutEqual(prevOpts.layoutInfo, newOpts.layoutInfo)),
|
||||
stylingInfo: (!this._stylingInfoEqual(prevOpts.stylingInfo, newOpts.stylingInfo)),
|
||||
wrappingInfo: (!this._wrappingInfoEqual(prevOpts.wrappingInfo, newOpts.wrappingInfo)),
|
||||
indentInfo: (!this._indentInfoEqual(prevOpts.indentInfo, newOpts.indentInfo)),
|
||||
observedOuterWidth: (prevOpts.observedOuterWidth !== newOpts.observedOuterWidth),
|
||||
observedOuterHeight: (prevOpts.observedOuterHeight !== newOpts.observedOuterHeight),
|
||||
observedOuterHeight: (prevOpts.observedOuterHeight !== newOpts.observedOuterHeight),
|
||||
lineHeight: (prevOpts.lineHeight !== newOpts.lineHeight),
|
||||
pageSize: (prevOpts.pageSize !== newOpts.pageSize),
|
||||
typicalHalfwidthCharacterWidth: (prevOpts.typicalHalfwidthCharacterWidth !== newOpts.typicalHalfwidthCharacterWidth),
|
||||
|
|
|
@ -54,6 +54,7 @@ export function renderLine(input:IRenderLineInput): IRenderLineOutput {
|
|||
let out: string[] = [];
|
||||
let charOffsetInPartArr: number[] = [];
|
||||
let charOffsetInPart = 0;
|
||||
let tabsCharDelta = 0;
|
||||
|
||||
out.push('<span>');
|
||||
for (let partIndex = 0, partIndexLen = actualLineParts.length; partIndex < partIndexLen; partIndex++) {
|
||||
|
@ -75,7 +76,6 @@ export function renderLine(input:IRenderLineInput): IRenderLineOutput {
|
|||
}
|
||||
|
||||
charOffsetInPart = 0;
|
||||
let tabsCharDelta = 0;
|
||||
for (; charIndex < toCharIndex; charIndex++) {
|
||||
charOffsetInPartArr[charIndex] = charOffsetInPart;
|
||||
let charCode = lineText.charCodeAt(charIndex);
|
||||
|
|
|
@ -186,4 +186,112 @@ suite('viewLineRenderer.renderLine', () => {
|
|||
assert.equal(_actual.output.join(''), '<span>' + expectedOutput + '</span>');
|
||||
assert.deepEqual(_actual.charOffsetInPart, expectedOffsets);
|
||||
});
|
||||
|
||||
test('issue #2255: Weird line rendering part 1', () => {
|
||||
let lineText = '\t\t\tcursorStyle:\t\t\t\t\t\t(prevOpts.cursorStyle !== newOpts.cursorStyle),';
|
||||
|
||||
let lineParts = [
|
||||
createPart( 0, 'block body decl declaration meta method object ts'), // 3 chars
|
||||
createPart( 3, 'block body decl declaration member meta method object ts'), // 12 chars
|
||||
createPart(15, 'block body decl declaration member meta method object ts'), // 6 chars
|
||||
createPart(21, 'delimiter paren typescript'), // 1 char
|
||||
createPart(22, 'block body decl declaration member meta method object ts'), // 21 chars
|
||||
createPart(43, 'block body comparison decl declaration keyword member meta method object operator ts'), // 2 chars
|
||||
createPart(45, 'block body comparison decl declaration keyword member meta method object operator ts'), // 1 char
|
||||
createPart(46, 'block body decl declaration member meta method object ts'), // 20 chars
|
||||
createPart(66, 'delimiter paren typescript'), // 1 char
|
||||
createPart(67, 'block body decl declaration meta method object ts'), // 2 chars
|
||||
];
|
||||
let expectedOutput = [
|
||||
'<span class="token block body decl declaration meta method object ts"> </span>',
|
||||
'<span class="token block body decl declaration member meta method object ts">cursorStyle:</span>',
|
||||
'<span class="token block body decl declaration member meta method object ts"> </span>',
|
||||
'<span class="token delimiter paren typescript">(</span>',
|
||||
'<span class="token block body decl declaration member meta method object ts">prevOpts.cursorStyle </span>',
|
||||
'<span class="token block body comparison decl declaration keyword member meta method object operator ts">!=</span>',
|
||||
'<span class="token block body comparison decl declaration keyword member meta method object operator ts">=</span>',
|
||||
'<span class="token block body decl declaration member meta method object ts"> newOpts.cursorStyle</span>',
|
||||
'<span class="token delimiter paren typescript">)</span>',
|
||||
'<span class="token block body decl declaration meta method object ts">,</span>',
|
||||
].join('');
|
||||
let expectedOffsetsArr = [
|
||||
[0, 4, 8], // 3 chars
|
||||
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], // 12 chars
|
||||
[0, 4, 8, 12, 16, 20], // 6 chars
|
||||
[0], // 1 char
|
||||
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], // 21 chars
|
||||
[0, 1], // 2 chars
|
||||
[0], // 1 char
|
||||
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], // 20 chars
|
||||
[0], // 1 char
|
||||
[0, 1] // 2 chars
|
||||
];
|
||||
let expectedOffsets = expectedOffsetsArr.reduce((prev, curr) => prev.concat(curr), []);
|
||||
|
||||
let _actual = renderLine({
|
||||
lineContent: lineText,
|
||||
tabSize: 4,
|
||||
stopRenderingLineAfter: -1,
|
||||
renderWhitespace: false,
|
||||
parts: lineParts
|
||||
});
|
||||
|
||||
assert.equal(_actual.output.join(''), '<span>' + expectedOutput + '</span>');
|
||||
assert.deepEqual(_actual.charOffsetInPart, expectedOffsets);
|
||||
});
|
||||
|
||||
test('issue #2255: Weird line rendering part 2', () => {
|
||||
let lineText = ' \t\t\tcursorStyle:\t\t\t\t\t\t(prevOpts.cursorStyle !== newOpts.cursorStyle),';
|
||||
|
||||
let lineParts = [
|
||||
createPart( 0, 'block body decl declaration meta method object ts'), // 4 chars
|
||||
createPart( 4, 'block body decl declaration member meta method object ts'), // 12 chars
|
||||
createPart(16, 'block body decl declaration member meta method object ts'), // 6 chars
|
||||
createPart(22, 'delimiter paren typescript'), // 1 char
|
||||
createPart(23, 'block body decl declaration member meta method object ts'), // 21 chars
|
||||
createPart(44, 'block body comparison decl declaration keyword member meta method object operator ts'), // 2 chars
|
||||
createPart(46, 'block body comparison decl declaration keyword member meta method object operator ts'), // 1 char
|
||||
createPart(47, 'block body decl declaration member meta method object ts'), // 20 chars
|
||||
createPart(67, 'delimiter paren typescript'), // 1 char
|
||||
createPart(68, 'block body decl declaration meta method object ts'), // 2 chars
|
||||
];
|
||||
let expectedOutput = [
|
||||
'<span class="token block body decl declaration meta method object ts"> </span>',
|
||||
'<span class="token block body decl declaration member meta method object ts">cursorStyle:</span>',
|
||||
'<span class="token block body decl declaration member meta method object ts"> </span>',
|
||||
'<span class="token delimiter paren typescript">(</span>',
|
||||
'<span class="token block body decl declaration member meta method object ts">prevOpts.cursorStyle </span>',
|
||||
'<span class="token block body comparison decl declaration keyword member meta method object operator ts">!=</span>',
|
||||
'<span class="token block body comparison decl declaration keyword member meta method object operator ts">=</span>',
|
||||
'<span class="token block body decl declaration member meta method object ts"> newOpts.cursorStyle</span>',
|
||||
'<span class="token delimiter paren typescript">)</span>',
|
||||
'<span class="token block body decl declaration meta method object ts">,</span>',
|
||||
].join('');
|
||||
let expectedOffsetsArr = [
|
||||
[0, 1, 4, 8], // 4 chars
|
||||
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], // 12 chars
|
||||
[0, 4, 8, 12, 16, 20], // 6 chars
|
||||
[0], // 1 char
|
||||
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], // 21 chars
|
||||
[0, 1], // 2 chars
|
||||
[0], // 1 char
|
||||
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], // 20 chars
|
||||
[0], // 1 char
|
||||
[0, 1] // 2 chars
|
||||
];
|
||||
let expectedOffsets = expectedOffsetsArr.reduce((prev, curr) => prev.concat(curr), []);
|
||||
|
||||
let _actual = renderLine({
|
||||
lineContent: lineText,
|
||||
tabSize: 4,
|
||||
stopRenderingLineAfter: -1,
|
||||
renderWhitespace: false,
|
||||
parts: lineParts
|
||||
});
|
||||
|
||||
assert.equal(_actual.output.join(''), '<span>' + expectedOutput + '</span>');
|
||||
assert.deepEqual(_actual.charOffsetInPart, expectedOffsets);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue