Merge VS Code 1.23.1 (#1520)

This commit is contained in:
Matt Irvine
2018-06-05 11:24:51 -07:00
committed by GitHub
parent e3baf5c443
commit 0c58f09e59
3651 changed files with 74249 additions and 48599 deletions

View File

@@ -7,9 +7,11 @@
import * as assert from 'assert';
import { Range } from 'vs/editor/common/core/range';
import { LinesTextBuffer, IValidatedEditOperation } from 'vs/editor/common/model/linesTextBuffer/linesTextBuffer';
import { PieceTreeTextBuffer, IValidatedEditOperation } from 'vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBuffer';
import { createTextBufferFactory } from 'vs/editor/common/model/textModel';
import { DefaultEndOfLine } from 'vs/editor/common/model';
suite('LinesTextBuffer._getInverseEdits', () => {
suite('PieceTreeTextBuffer._getInverseEdits', () => {
function editOp(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number, text: string[]): IValidatedEditOperation {
return {
@@ -29,7 +31,7 @@ suite('LinesTextBuffer._getInverseEdits', () => {
}
function assertInverseEdits(ops: IValidatedEditOperation[], expected: Range[]): void {
var actual = LinesTextBuffer._getInverseEditRanges(ops);
var actual = PieceTreeTextBuffer._getInverseEditRanges(ops);
assert.deepEqual(actual, expected);
}
@@ -260,7 +262,7 @@ suite('LinesTextBuffer._getInverseEdits', () => {
});
});
suite('LinesTextBuffer._toSingleEditOperation', () => {
suite('PieceTreeTextBuffer._toSingleEditOperation', () => {
function editOp(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number, rangeOffset: number, rangeLength: number, text: string[]): IValidatedEditOperation {
return {
@@ -276,13 +278,7 @@ suite('LinesTextBuffer._toSingleEditOperation', () => {
}
function testToSingleEditOperation(original: string[], edits: IValidatedEditOperation[], expected: IValidatedEditOperation): void {
const textBuffer = new LinesTextBuffer({
BOM: '',
EOL: '\n',
containsRTL: false,
isBasicASCII: true,
lines: original
});
const textBuffer = <PieceTreeTextBuffer>createTextBufferFactory(original.join('\n')).create(DefaultEndOfLine.LF);
const actual = textBuffer._toSingleEditOperation(edits);
assert.deepEqual(actual, expected);

View File

@@ -5,150 +5,69 @@
'use strict';
import * as assert from 'assert';
import { LinesTextBufferBuilder } from 'vs/editor/common/model/linesTextBuffer/linesTextBufferBuilder';
import { ITextModelCreationOptions } from 'vs/editor/common/model';
import { TextModel } from 'vs/editor/common/model/textModel';
import { DefaultEndOfLine } from 'vs/editor/common/model';
import { createTextBufferFactory } from 'vs/editor/common/model/textModel';
import * as strings from 'vs/base/common/strings';
import { IRawTextSource } from 'vs/editor/common/model/linesTextBuffer/textSource';
import { PieceTreeTextBuffer } from 'vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBuffer';
class RawTextSource {
public static fromString(rawText: string): IRawTextSource {
// Count the number of lines that end with \r\n
let carriageReturnCnt = 0;
let lastCarriageReturnIndex = -1;
while ((lastCarriageReturnIndex = rawText.indexOf('\r', lastCarriageReturnIndex + 1)) !== -1) {
carriageReturnCnt++;
}
export function testTextBufferFactory(text: string, eol: string, mightContainNonBasicASCII: boolean, mightContainRTL: boolean): void {
const textBuffer = <PieceTreeTextBuffer>createTextBufferFactory(text).create(DefaultEndOfLine.LF);
const containsRTL = strings.containsRTL(rawText);
const isBasicASCII = (containsRTL ? false : strings.isBasicASCII(rawText));
// Split the text into lines
const lines = rawText.split(/\r\n|\r|\n/);
// Remove the BOM (if present)
let BOM = '';
if (strings.startsWithUTF8BOM(lines[0])) {
BOM = strings.UTF8_BOM_CHARACTER;
lines[0] = lines[0].substr(1);
}
return {
BOM: BOM,
lines: lines,
containsRTL: containsRTL,
isBasicASCII: isBasicASCII,
totalCRCount: carriageReturnCnt
};
}
}
export function testModelBuilder(chunks: string[], opts: ITextModelCreationOptions = TextModel.DEFAULT_CREATION_OPTIONS): void {
let expectedTextSource = RawTextSource.fromString(chunks.join(''));
let builder = new LinesTextBufferBuilder();
for (let i = 0, len = chunks.length; i < len; i++) {
builder.acceptChunk(chunks[i]);
}
let actual = builder.finish();
assert.deepEqual(actual.rawTextSource, expectedTextSource);
assert.equal(textBuffer.mightContainNonBasicASCII(), mightContainNonBasicASCII);
assert.equal(textBuffer.mightContainRTL(), mightContainRTL);
assert.equal(textBuffer.getEOL(), eol);
}
suite('ModelBuilder', () => {
test('no chunks', () => {
testModelBuilder([]);
test('t1', () => {
testTextBufferFactory('', '\n', false, false);
});
test('single empty chunk', () => {
testModelBuilder(['']);
test('t2', () => {
testTextBufferFactory('Hello world', '\n', false, false);
});
test('single line in one chunk', () => {
testModelBuilder(['Hello world']);
test('t3', () => {
testTextBufferFactory('Hello world\nHow are you?', '\n', false, false);
});
test('single line in multiple chunks', () => {
testModelBuilder(['Hello', ' ', 'world']);
});
test('two lines in single chunk', () => {
testModelBuilder(['Hello world\nHow are you?']);
});
test('two lines in multiple chunks 1', () => {
testModelBuilder(['Hello worl', 'd\nHow are you?']);
});
test('two lines in multiple chunks 2', () => {
testModelBuilder(['Hello worl', 'd', '\n', 'H', 'ow are you?']);
});
test('two lines in multiple chunks 3', () => {
testModelBuilder(['Hello worl', 'd', '\nHow are you?']);
});
test('multiple lines in single chunks', () => {
testModelBuilder(['Hello world\nHow are you?\nIs everything good today?\nDo you enjoy the weather?']);
});
test('multiple lines in multiple chunks 1', () => {
testModelBuilder(['Hello world\nHow are you', '?\nIs everything good today?\nDo you enjoy the weather?']);
});
test('multiple lines in multiple chunks 1', () => {
testModelBuilder(['Hello world', '\nHow are you', '?\nIs everything good today?', '\nDo you enjoy the weather?']);
});
test('multiple lines in multiple chunks 1', () => {
testModelBuilder(['Hello world\n', 'How are you', '?\nIs everything good today?', '\nDo you enjoy the weather?']);
test('t4', () => {
testTextBufferFactory('Hello world\nHow are you?\nIs everything good today?\nDo you enjoy the weather?', '\n', false, false);
});
test('carriage return detection (1 \\r\\n 2 \\n)', () => {
testModelBuilder(['Hello world\r\n', 'How are you', '?\nIs everything good today?', '\nDo you enjoy the weather?']);
testTextBufferFactory('Hello world\r\nHow are you?\nIs everything good today?\nDo you enjoy the weather?', '\n', false, false);
});
test('carriage return detection (2 \\r\\n 1 \\n)', () => {
testModelBuilder(['Hello world\r\n', 'How are you', '?\r\nIs everything good today?', '\nDo you enjoy the weather?']);
testTextBufferFactory('Hello world\r\nHow are you?\r\nIs everything good today?\nDo you enjoy the weather?', '\r\n', false, false);
});
test('carriage return detection (3 \\r\\n 0 \\n)', () => {
testModelBuilder(['Hello world\r\n', 'How are you', '?\r\nIs everything good today?', '\r\nDo you enjoy the weather?']);
});
test('carriage return detection (isolated \\r)', () => {
testModelBuilder(['Hello world', '\r', '\n', 'How are you', '?', '\r', '\n', 'Is everything good today?', '\r', '\n', 'Do you enjoy the weather?']);
testTextBufferFactory('Hello world\r\nHow are you?\r\nIs everything good today?\r\nDo you enjoy the weather?', '\r\n', false, false);
});
test('BOM handling', () => {
testModelBuilder([strings.UTF8_BOM_CHARACTER + 'Hello world!']);
testTextBufferFactory(strings.UTF8_BOM_CHARACTER + 'Hello world!', '\n', false, false);
});
test('BOM handling', () => {
testModelBuilder([strings.UTF8_BOM_CHARACTER, 'Hello world!']);
});
test('RTL handling 1', () => {
testModelBuilder(['Hello world!', 'זוהי עובדה מבוססת שדעתו']);
testTextBufferFactory(strings.UTF8_BOM_CHARACTER + 'Hello world!', '\n', false, false);
});
test('RTL handling 2', () => {
testModelBuilder(['Hello world!זוהי עובדה מבוססת שדעתו']);
testTextBufferFactory('Hello world!זוהי עובדה מבוססת שדעתו', '\n', true, true);
});
test('RTL handling 3', () => {
testModelBuilder(['Hello world!זוהי \nעובדה מבוססת שדעתו']);
testTextBufferFactory('Hello world!זוהי \nעובדה מבוססת שדעתו', '\n', true, true);
});
test('ASCII handling 1', () => {
testModelBuilder(['Hello world!!\nHow do you do?']);
testTextBufferFactory('Hello world!!\nHow do you do?', '\n', false, false);
});
test('ASCII handling 1', () => {
testModelBuilder(['Hello world!!\nHow do you do?Züricha📚📚b']);
});
test('issue #32819: some special string cannot be displayed completely', () => {
testModelBuilder(['123']);
test('ASCII handling 2', () => {
testTextBufferFactory('Hello world!!\nHow do you do?Züricha📚📚b', '\n', true, false);
});
});

View File

@@ -1,97 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import { testModelBuilder } from './linesTextBufferBuilder.test';
import { getRandomInt, getRandomEOLSequence, getRandomString } from 'vs/editor/test/common/model/linesTextBuffer/textBufferAutoTestUtils';
const GENERATE_TESTS = false;
suite('ModelBuilder Auto Tests', () => {
test('auto1', () => {
testModelBuilder(['sarjniow', '\r', '\nbpb', 'ofb', '\njzldgxx', '\r\nkzwfjysng']);
});
test('auto2', () => {
testModelBuilder(['i', 'yyernubi\r\niimgn\n', 'ut\r']);
});
});
function generateRandomFile(): string {
let lineCount = getRandomInt(1, 10);
let mixedEOLSequence = getRandomInt(1, 2) === 1 ? true : false;
let fixedEOL = getRandomEOLSequence();
let lines: string[] = [];
for (let i = 0; i < lineCount; i++) {
if (i !== 0) {
if (mixedEOLSequence) {
lines.push(getRandomEOLSequence());
} else {
lines.push(fixedEOL);
}
}
lines.push(getRandomString(0, 10));
}
return lines.join('');
}
function generateRandomChunks(file: string): string[] {
let result: string[] = [];
let cnt = getRandomInt(1, 20);
let maxOffset = file.length;
while (cnt > 0 && maxOffset > 0) {
let offset = getRandomInt(0, maxOffset);
result.unshift(file.substring(offset, maxOffset));
// let length = getRandomInt(0, maxOffset - offset);
// let text = generateFile(true);
// result.push({
// offset: offset,
// length: length,
// text: text
// });
maxOffset = offset;
cnt--;
}
if (maxOffset !== 0) {
result.unshift(file.substring(0, maxOffset));
}
return result;
}
function testRandomFile(file: string): boolean {
let tests = getRandomInt(5, 10);
for (let i = 0; i < tests; i++) {
let chunks = generateRandomChunks(file);
try {
testModelBuilder(chunks);
} catch (err) {
console.log(err);
console.log(JSON.stringify(chunks));
return false;
}
}
return true;
}
if (GENERATE_TESTS) {
let number = 1;
while (true) {
console.log('------BEGIN NEW TEST: ' + number);
if (!testRandomFile(generateRandomFile())) {
break;
}
console.log('------END NEW TEST: ' + (number++));
}
}