Merge from vscode 52dcb723a39ae75bee1bd56b3312d7fcdc87aeed (#6719)

This commit is contained in:
Anthony Dresser
2019-08-12 21:31:51 -07:00
committed by GitHub
parent 00250839fc
commit 7eba8c4c03
616 changed files with 9472 additions and 7087 deletions

View File

@@ -608,6 +608,46 @@ suite('Editor Model - TextModel', () => {
]);
});
test('issue #62143: Broken indentation detection', () => {
// works before the fix
assertGuess(true, 2, [
'x',
'x',
' x',
' x'
]);
// works before the fix
assertGuess(true, 2, [
'x',
' - item2',
' - item3'
]);
// works before the fix
testGuessIndentation(true, 2, true, 2, [
'x x',
' x',
' x',
]);
// fails before the fix
// empty space inline breaks the indentation guess
testGuessIndentation(true, 2, true, 2, [
'x x',
' x',
' x',
' x'
]);
testGuessIndentation(true, 2, true, 2, [
'<!--test1.md -->',
'- item1',
' - item2',
' - item3'
]);
});
test('validatePosition', () => {
let m = TextModel.createFromString('line one\nline two');

View File

@@ -109,9 +109,9 @@ suite('Editor Modes - textToHtmlTokenizer', () => {
[
'<div>',
'<span style="color: #ff0000;font-style: italic;font-weight: bold;">Ciao</span>',
'<span style="color: #000000;"> </span>',
'<span style="color: #000000;">&nbsp</span>',
'<span style="color: #00ff00;">hello</span>',
'<span style="color: #000000;"> </span>',
'<span style="color: #000000;">&nbsp</span>',
'<span style="color: #0000ff;text-decoration: underline;">world!</span>',
'</div>'
].join('')
@@ -122,9 +122,9 @@ suite('Editor Modes - textToHtmlTokenizer', () => {
[
'<div>',
'<span style="color: #ff0000;font-style: italic;font-weight: bold;">Ciao</span>',
'<span style="color: #000000;"> </span>',
'<span style="color: #000000;">&nbsp</span>',
'<span style="color: #00ff00;">hello</span>',
'<span style="color: #000000;"> </span>',
'<span style="color: #000000;">&nbsp</span>',
'<span style="color: #0000ff;text-decoration: underline;">w</span>',
'</div>'
].join('')
@@ -135,9 +135,9 @@ suite('Editor Modes - textToHtmlTokenizer', () => {
[
'<div>',
'<span style="color: #ff0000;font-style: italic;font-weight: bold;">Ciao</span>',
'<span style="color: #000000;"> </span>',
'<span style="color: #000000;">&nbsp</span>',
'<span style="color: #00ff00;">hello</span>',
'<span style="color: #000000;"> </span>',
'<span style="color: #000000;">&nbsp</span>',
'</div>'
].join('')
);
@@ -147,9 +147,9 @@ suite('Editor Modes - textToHtmlTokenizer', () => {
[
'<div>',
'<span style="color: #ff0000;font-style: italic;font-weight: bold;">iao</span>',
'<span style="color: #000000;"> </span>',
'<span style="color: #000000;">&nbsp</span>',
'<span style="color: #00ff00;">hello</span>',
'<span style="color: #000000;"> </span>',
'<span style="color: #000000;">&nbsp</span>',
'</div>'
].join('')
);
@@ -158,9 +158,9 @@ suite('Editor Modes - textToHtmlTokenizer', () => {
tokenizeLineToHTML(text, lineTokens, colorMap, 4, 11, 4),
[
'<div>',
'<span style="color: #000000;"> </span>',
'<span style="color: #000000;">&nbsp</span>',
'<span style="color: #00ff00;">hello</span>',
'<span style="color: #000000;"> </span>',
'<span style="color: #000000;">&nbsp</span>',
'</div>'
].join('')
);
@@ -170,7 +170,7 @@ suite('Editor Modes - textToHtmlTokenizer', () => {
[
'<div>',
'<span style="color: #00ff00;">hello</span>',
'<span style="color: #000000;"> </span>',
'<span style="color: #000000;">&nbsp</span>',
'</div>'
].join('')
);
@@ -193,6 +193,88 @@ suite('Editor Modes - textToHtmlTokenizer', () => {
].join('')
);
});
test('tokenizeLineToHTML handle spaces #35954', () => {
const text = ' Ciao hello world!';
const lineTokens = new ViewLineTokens([
new ViewLineToken(
2,
(
(1 << MetadataConsts.FOREGROUND_OFFSET)
) >>> 0
),
new ViewLineToken(
6,
(
(3 << MetadataConsts.FOREGROUND_OFFSET)
| ((FontStyle.Bold | FontStyle.Italic) << MetadataConsts.FONT_STYLE_OFFSET)
) >>> 0
),
new ViewLineToken(
9,
(
(1 << MetadataConsts.FOREGROUND_OFFSET)
) >>> 0
),
new ViewLineToken(
14,
(
(4 << MetadataConsts.FOREGROUND_OFFSET)
) >>> 0
),
new ViewLineToken(
15,
(
(1 << MetadataConsts.FOREGROUND_OFFSET)
) >>> 0
),
new ViewLineToken(
21,
(
(5 << MetadataConsts.FOREGROUND_OFFSET)
| ((FontStyle.Underline) << MetadataConsts.FONT_STYLE_OFFSET)
) >>> 0
)
]);
const colorMap = [null!, '#000000', '#ffffff', '#ff0000', '#00ff00', '#0000ff'];
assert.equal(
tokenizeLineToHTML(text, lineTokens, colorMap, 0, 21, 4),
[
'<div>',
'<span style="color: #000000;">&nbsp&nbsp</span>',
'<span style="color: #ff0000;font-style: italic;font-weight: bold;">Ciao</span>',
'<span style="color: #000000;">&nbsp&nbsp&nbsp</span>',
'<span style="color: #00ff00;">hello</span>',
'<span style="color: #000000;">&nbsp</span>',
'<span style="color: #0000ff;text-decoration: underline;">world!</span>',
'</div>'
].join('')
);
assert.equal(
tokenizeLineToHTML(text, lineTokens, colorMap, 0, 17, 4),
[
'<div>',
'<span style="color: #000000;">&nbsp&nbsp</span>',
'<span style="color: #ff0000;font-style: italic;font-weight: bold;">Ciao</span>',
'<span style="color: #000000;">&nbsp&nbsp&nbsp</span>',
'<span style="color: #00ff00;">hello</span>',
'<span style="color: #000000;">&nbsp</span>',
'<span style="color: #0000ff;text-decoration: underline;">wo</span>',
'</div>'
].join('')
);
assert.equal(
tokenizeLineToHTML(text, lineTokens, colorMap, 0, 3, 4),
[
'<div>',
'<span style="color: #000000;">&nbsp&nbsp</span>',
'<span style="color: #ff0000;font-style: italic;font-weight: bold;">C</span>',
'</div>'
].join('')
);
});
});

View File

@@ -114,6 +114,11 @@ suite('Editor ViewModel - CharacterHardWrappingLineMapper', () => {
assert.equal(mapper!.getWrappedLinesIndent(), ' \t');
});
test('issue #75494: surrogate pairs', () => {
let factory = new CharacterHardWrappingLineMapperFactory('', ' ', '');
assertLineMapping(factory, 4, 49, '🐇👬🌖🌞🏇🍼🐇👬🌖🌞🏇🍼🐇👬🌖🌞🏇🍼🐇👬🌖🌞🏇🍼🐇|👬🌖🌞🏇🍼🐇👬🌖🌞🏇🍼🐇👬🌖🌞🏇🍼🐇👬🌖🌞🏇🍼🐇👬', WrappingIndent.Same);
});
test('CharacterHardWrappingLineMapper - WrappingIndent.DeepIndent', () => {
let factory = new CharacterHardWrappingLineMapperFactory('', ' ', '');
let mapper = assertLineMapping(factory, 4, 26, ' W e A r e T e s t |i n g D e |e p I n d |e n t a t |i o n', WrappingIndent.DeepIndent);