Merge from vscode 81d7885dc2e9dc617e1522697a2966bc4025a45d (#5949)

* Merge from vscode 81d7885dc2e9dc617e1522697a2966bc4025a45d

* Fix vs unit tests and hygiene issue

* Fix strict null check issue
This commit is contained in:
Chris LaFreniere
2019-06-10 18:27:09 -07:00
committed by GitHub
parent ff38bc8143
commit d15a3fcc98
926 changed files with 19529 additions and 11383 deletions

View File

@@ -26,17 +26,21 @@ function testGuessIndentation(defaultInsertSpaces: boolean, defaultTabSize: numb
assert.equal(r.tabSize, expectedTabSize, msg);
}
function assertGuess(expectedInsertSpaces: boolean | undefined, expectedTabSize: number | undefined, text: string[], msg?: string): void {
function assertGuess(expectedInsertSpaces: boolean | undefined, expectedTabSize: number | undefined | [number], text: string[], msg?: string): void {
if (typeof expectedInsertSpaces === 'undefined') {
// cannot guess insertSpaces
if (typeof expectedTabSize === 'undefined') {
// cannot guess tabSize
testGuessIndentation(true, 13370, true, 13370, text, msg);
testGuessIndentation(false, 13371, false, 13371, text, msg);
} else {
} else if (typeof expectedTabSize === 'number') {
// can guess tabSize
testGuessIndentation(true, 13370, true, expectedTabSize, text, msg);
testGuessIndentation(false, 13371, false, expectedTabSize, text, msg);
} else {
// can only guess tabSize when insertSpaces is true
testGuessIndentation(true, 13370, true, expectedTabSize[0], text, msg);
testGuessIndentation(false, 13371, false, 13371, text, msg);
}
} else {
// can guess insertSpaces
@@ -44,10 +48,19 @@ function assertGuess(expectedInsertSpaces: boolean | undefined, expectedTabSize:
// cannot guess tabSize
testGuessIndentation(true, 13370, expectedInsertSpaces, 13370, text, msg);
testGuessIndentation(false, 13371, expectedInsertSpaces, 13371, text, msg);
} else {
} else if (typeof expectedTabSize === 'number') {
// can guess tabSize
testGuessIndentation(true, 13370, expectedInsertSpaces, expectedTabSize, text, msg);
testGuessIndentation(false, 13371, expectedInsertSpaces, expectedTabSize, text, msg);
} else {
// can only guess tabSize when insertSpaces is true
if (expectedInsertSpaces === true) {
testGuessIndentation(true, 13370, expectedInsertSpaces, expectedTabSize[0], text, msg);
testGuessIndentation(false, 13371, expectedInsertSpaces, expectedTabSize[0], text, msg);
} else {
testGuessIndentation(true, 13370, expectedInsertSpaces, 13370, text, msg);
testGuessIndentation(false, 13371, expectedInsertSpaces, 13371, text, msg);
}
}
}
}
@@ -219,7 +232,7 @@ suite('Editor Model - TextModel', () => {
'\tx'
], '7xTAB');
assertGuess(undefined, 2, [
assertGuess(undefined, [2], [
'\tx',
' x',
'\tx',
@@ -239,7 +252,7 @@ suite('Editor Model - TextModel', () => {
'\tx',
' x'
], '4x1, 4xTAB');
assertGuess(false, 2, [
assertGuess(false, undefined, [
'\tx',
'\tx',
' x',
@@ -250,7 +263,7 @@ suite('Editor Model - TextModel', () => {
'\tx',
' x',
], '4x2, 5xTAB');
assertGuess(false, 2, [
assertGuess(false, undefined, [
'\tx',
'\tx',
'x',
@@ -261,7 +274,7 @@ suite('Editor Model - TextModel', () => {
'\tx',
' x',
], '1x2, 5xTAB');
assertGuess(false, 4, [
assertGuess(false, undefined, [
'\tx',
'\tx',
'x',
@@ -272,7 +285,7 @@ suite('Editor Model - TextModel', () => {
'\tx',
' x',
], '1x4, 5xTAB');
assertGuess(false, 2, [
assertGuess(false, undefined, [
'\tx',
'\tx',
'x',
@@ -524,7 +537,7 @@ suite('Editor Model - TextModel', () => {
' \t x',
'\tx'
], 'mixed whitespace 1');
assertGuess(false, 4, [
assertGuess(false, undefined, [
'\tx',
'\t x'
], 'mixed whitespace 2');
@@ -575,6 +588,26 @@ suite('Editor Model - TextModel', () => {
]);
});
test('issue #70832: Broken indentation detection', () => {
assertGuess(false, undefined, [
'x',
'x',
'x',
'x',
' x',
' x',
' x',
' x',
' x',
' x',
' x',
' x',
' x',
' x',
'x',
]);
});
test('validatePosition', () => {
let m = TextModel.createFromString('line one\nline two');