mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-07 09:35:41 -05:00
Merge VS Code 1.31.1 (#4283)
This commit is contained in:
@@ -21,16 +21,16 @@ class StringDiffSequence implements ISequence {
|
||||
}
|
||||
|
||||
function createArray<T>(length: number, value: T): T[] {
|
||||
var r = [];
|
||||
for (var i = 0; i < length; i++) {
|
||||
const r: T[] = [];
|
||||
for (let i = 0; i < length; i++) {
|
||||
r[i] = value;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
function maskBasedSubstring(str: string, mask: boolean[]): string {
|
||||
var r = '';
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
let r = '';
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
if (mask[i]) {
|
||||
r += str.charAt(i);
|
||||
}
|
||||
@@ -39,10 +39,10 @@ function maskBasedSubstring(str: string, mask: boolean[]): string {
|
||||
}
|
||||
|
||||
function assertAnswer(originalStr: string, modifiedStr: string, changes: IDiffChange[], answerStr: string, onlyLength: boolean = false): void {
|
||||
var originalMask = createArray(originalStr.length, true);
|
||||
var modifiedMask = createArray(modifiedStr.length, true);
|
||||
let originalMask = createArray(originalStr.length, true);
|
||||
let modifiedMask = createArray(modifiedStr.length, true);
|
||||
|
||||
var i, j, change;
|
||||
let i, j, change;
|
||||
for (i = 0; i < changes.length; i++) {
|
||||
change = changes[i];
|
||||
|
||||
@@ -59,8 +59,8 @@ function assertAnswer(originalStr: string, modifiedStr: string, changes: IDiffCh
|
||||
}
|
||||
}
|
||||
|
||||
var originalAnswer = maskBasedSubstring(originalStr, originalMask);
|
||||
var modifiedAnswer = maskBasedSubstring(modifiedStr, modifiedMask);
|
||||
let originalAnswer = maskBasedSubstring(originalStr, originalMask);
|
||||
let modifiedAnswer = maskBasedSubstring(modifiedStr, modifiedMask);
|
||||
|
||||
if (onlyLength) {
|
||||
assert.equal(originalAnswer.length, answerStr.length);
|
||||
@@ -72,14 +72,14 @@ function assertAnswer(originalStr: string, modifiedStr: string, changes: IDiffCh
|
||||
}
|
||||
|
||||
function lcsInnerTest(Algorithm: any, originalStr: string, modifiedStr: string, answerStr: string, onlyLength: boolean = false): void {
|
||||
var diff = new Algorithm(new StringDiffSequence(originalStr), new StringDiffSequence(modifiedStr));
|
||||
var changes = diff.ComputeDiff();
|
||||
let diff = new Algorithm(new StringDiffSequence(originalStr), new StringDiffSequence(modifiedStr));
|
||||
let changes = diff.ComputeDiff();
|
||||
assertAnswer(originalStr, modifiedStr, changes, answerStr, onlyLength);
|
||||
}
|
||||
|
||||
function stringPower(str: string, power: number): string {
|
||||
var r = str;
|
||||
for (var i = 0; i < power; i++) {
|
||||
let r = str;
|
||||
for (let i = 0; i < power; i++) {
|
||||
r += r;
|
||||
}
|
||||
return r;
|
||||
@@ -87,7 +87,7 @@ function stringPower(str: string, power: number): string {
|
||||
|
||||
function lcsTest(Algorithm: any, originalStr: string, modifiedStr: string, answerStr: string) {
|
||||
lcsInnerTest(Algorithm, originalStr, modifiedStr, answerStr);
|
||||
for (var i = 2; i <= 5; i++) {
|
||||
for (let i = 2; i <= 5; i++) {
|
||||
lcsInnerTest(Algorithm, stringPower(originalStr, i), stringPower(modifiedStr, i), stringPower(answerStr, i), true);
|
||||
}
|
||||
}
|
||||
@@ -116,14 +116,14 @@ suite('Diff', () => {
|
||||
|
||||
suite('Diff - Ported from VS', () => {
|
||||
test('using continue processing predicate to quit early', function () {
|
||||
var left = 'abcdef';
|
||||
var right = 'abxxcyyydzzzzezzzzzzzzzzzzzzzzzzzzf';
|
||||
let left = 'abcdef';
|
||||
let right = 'abxxcyyydzzzzezzzzzzzzzzzzzzzzzzzzf';
|
||||
|
||||
// We use a long non-matching portion at the end of the right-side string, so the backwards tracking logic
|
||||
// doesn't get there first.
|
||||
var predicateCallCount = 0;
|
||||
let predicateCallCount = 0;
|
||||
|
||||
var diff = new LcsDiff(new StringDiffSequence(left), new StringDiffSequence(right), function (leftIndex, leftSequence, longestMatchSoFar) {
|
||||
let diff = new LcsDiff(new StringDiffSequence(left), new StringDiffSequence(right), function (leftIndex, leftSequence, longestMatchSoFar) {
|
||||
assert.equal(predicateCallCount, 0);
|
||||
|
||||
predicateCallCount++;
|
||||
@@ -134,7 +134,7 @@ suite('Diff - Ported from VS', () => {
|
||||
// cancel processing
|
||||
return false;
|
||||
});
|
||||
var changes = diff.ComputeDiff(true);
|
||||
let changes = diff.ComputeDiff(true);
|
||||
|
||||
assert.equal(predicateCallCount, 1);
|
||||
|
||||
@@ -170,11 +170,11 @@ suite('Diff - Ported from VS', () => {
|
||||
|
||||
|
||||
// Cancel *one iteration* after the second match ('d')
|
||||
var hitSecondMatch = false;
|
||||
let hitSecondMatch = false;
|
||||
diff = new LcsDiff(new StringDiffSequence(left), new StringDiffSequence(right), function (leftIndex, leftSequence, longestMatchSoFar) {
|
||||
assert(longestMatchSoFar <= 2); // We never see a match of length > 2
|
||||
|
||||
var hitYet = hitSecondMatch;
|
||||
let hitYet = hitSecondMatch;
|
||||
hitSecondMatch = longestMatchSoFar > 1;
|
||||
// Continue processing as long as there hasn't been a match made.
|
||||
return !hitYet;
|
||||
|
||||
Reference in New Issue
Block a user