Skip to content

Commit af3ac69

Browse files
committed
Update and reorganize
1 parent a8a7f08 commit af3ac69

28 files changed

+3797
-1585
lines changed

package-lock.json

Lines changed: 977 additions & 471 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
"dependencies": {},
88
"devDependencies": {
99
"@types/assert": "^1.5.6",
10-
"@types/mocha": "^8.2.0",
10+
"@types/mocha": "^9.1.1",
1111
"assert": "^2.0.0",
12-
"mocha": "^8.2.1",
13-
"ts-node": "^10.2.1",
14-
"typescript": "^4.4.3"
12+
"mocha": "^9.2.2",
13+
"ts-node": "^10.9.1",
14+
"typescript": "^5.0.4"
1515
},
1616
"scripts": {
1717
"test": "mocha -u tdd --require ts-node/register test/**/*.ts",

src/editorCommon.ts

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/index.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
export * from './diffComputer';
2-
export * from './diff';
3-
export * from './charCode';
4-
export * from './diffChange';
5-
export * from './editorCommon';
6-
export * from './strings';
1+
export * from 'vs/editor/common/diff/linesDiffComputer';
2+
export * from './vs/base/common/diff/diff';
3+
export * from './vs/base/common/diff/diffChange';
4+
export * from './vs/editor/common/diff/smartLinesDiffComputer';
5+
export * from './vs/editor/common/diff/standardLinesDiffComputer';

src/vs/base/common/assert.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import { BugIndicatingError, onUnexpectedError } from 'vs/base/common/errors';
7+
8+
/**
9+
* Throws an error with the provided message if the provided value does not evaluate to a true Javascript value.
10+
*
11+
* @deprecated Use `assert(...)` instead.
12+
* This method is usually used like this:
13+
* ```ts
14+
* import * as assert from 'vs/base/common/assert';
15+
* assert.ok(...);
16+
* ```
17+
*
18+
* However, `assert` in that example is a user chosen name.
19+
* There is no tooling for generating such an import statement.
20+
* Thus, the `assert(...)` function should be used instead.
21+
*/
22+
export function ok(value?: unknown, message?: string) {
23+
if (!value) {
24+
throw new Error(message ? `Assertion failed (${message})` : 'Assertion Failed');
25+
}
26+
}
27+
28+
export function assertNever(value: never, message = 'Unreachable'): never {
29+
throw new Error(message);
30+
}
31+
32+
export function assert(condition: boolean): void {
33+
if (!condition) {
34+
throw new BugIndicatingError('Assertion Failed');
35+
}
36+
}
37+
38+
/**
39+
* condition must be side-effect free!
40+
*/
41+
export function assertFn(condition: () => boolean): void {
42+
if (!condition()) {
43+
// eslint-disable-next-line no-debugger
44+
debugger;
45+
// Reevaluate `condition` again to make debugging easier
46+
condition();
47+
onUnexpectedError(new BugIndicatingError('Assertion Failed'));
48+
}
49+
}
50+
51+
export function checkAdjacentItems<T>(items: readonly T[], predicate: (item1: T, item2: T) => boolean): boolean {
52+
let i = 0;
53+
while (i < items.length - 1) {
54+
const a = items[i];
55+
const b = items[i + 1];
56+
if (!predicate(a, b)) {
57+
return false;
58+
}
59+
i++;
60+
}
61+
return true;
62+
}

src/charCode.ts renamed to src/vs/base/common/charCode.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// Updated from commit 94428f89bf25e3df92827c5bc677da8452aa7d12 - vscode/src/vs/base/common/charCode.ts
21
/*---------------------------------------------------------------------------------------------
32
* Copyright (c) Microsoft Corporation. All rights reserved.
43
* Licensed under the MIT License. See License.txt in the project root for license information.
@@ -10,7 +9,7 @@
109
* An inlined enum containing useful character codes (to be used with String.charCodeAt).
1110
* Please leave the const keyword such that it gets inlined when compiled to JavaScript!
1211
*/
13-
export const enum CharCode {
12+
export const enum CharCode {
1413
Null = 0,
1514
/**
1615
* The `\b` character.
@@ -226,6 +225,12 @@
226225
*/
227226
Tilde = 126,
228227

228+
/**
229+
* The &nbsp; (no-break space) character.
230+
* Unicode Character 'NO-BREAK SPACE' (U+00A0)
231+
*/
232+
NoBreakSpace = 160,
233+
229234
U_Combining_Grave_Accent = 0x0300, // U+0300 Combining Grave Accent
230235
U_Combining_Acute_Accent = 0x0301, // U+0301 Combining Acute Accent
231236
U_Combining_Circumflex_Accent = 0x0302, // U+0302 Combining Circumflex Accent
@@ -424,6 +429,12 @@
424429
U_GREEK_OXIA = 0x1FFD, // U+1FFD GREEK OXIA
425430
U_GREEK_DASIA = 0x1FFE, // U+1FFE GREEK DASIA
426431

432+
U_IDEOGRAPHIC_FULL_STOP = 0x3002, // U+3002 IDEOGRAPHIC FULL STOP
433+
U_LEFT_CORNER_BRACKET = 0x300C, // U+300C LEFT CORNER BRACKET
434+
U_RIGHT_CORNER_BRACKET = 0x300D, // U+300D RIGHT CORNER BRACKET
435+
U_LEFT_BLACK_LENTICULAR_BRACKET = 0x3010, // U+3010 LEFT BLACK LENTICULAR BRACKET
436+
U_RIGHT_BLACK_LENTICULAR_BRACKET = 0x3011, // U+3011 RIGHT BLACK LENTICULAR BRACKET
437+
427438

428439
U_OVERLINE = 0x203E, // Unicode Character 'OVERLINE'
429440

@@ -432,5 +443,8 @@
432443
* Unicode Character 'ZERO WIDTH NO-BREAK SPACE' (U+FEFF)
433444
* http://www.fileformat.info/info/unicode/char/feff/index.htm
434445
*/
435-
UTF8_BOM = 65279
446+
UTF8_BOM = 65279,
447+
448+
U_FULLWIDTH_SEMICOLON = 0xFF1B, // U+FF1B FULLWIDTH SEMICOLON
449+
U_FULLWIDTH_COMMA = 0xFF0C, // U+FF0C FULLWIDTH COMMA
436450
}

src/diff.ts renamed to src/vs/base/common/diff/diff.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
// Updated from commit 77905c850e170eab00cac5ca190c7b1fe5ad43ba - vscode/src/vs/base/common/diff/diff.ts
21
/*---------------------------------------------------------------------------------------------
32
* Copyright (c) Microsoft Corporation. All rights reserved.
43
* Licensed under the MIT License. See License.txt in the project root for license information.
54
*--------------------------------------------------------------------------------------------*/
65

7-
import { DiffChange } from './diffChange';
8-
import { stringHash } from './hash';
9-
import { Constants } from './uint';
6+
import { DiffChange } from 'vs/base/common/diff/diffChange';
7+
import { stringHash } from 'vs/base/common/hash';
8+
import { Constants } from 'vs/base/common/uint';
109

1110
export class StringDiffSequence implements ISequence {
1211

@@ -70,7 +69,7 @@ export interface IDiffResult {
7069
// The code below has been ported from a C# implementation in VS
7170
//
7271

73-
export class Debug {
72+
class Debug {
7473

7574
public static Assert(condition: boolean, message: string): void {
7675
if (!condition) {
@@ -79,7 +78,7 @@ export class Debug {
7978
}
8079
}
8180

82-
export class MyArray {
81+
class MyArray {
8382
/**
8483
* Copies a range of elements from an Array starting at the specified source index and pastes
8584
* them to another Array starting at the specified destination index. The length and the indexes
@@ -852,7 +851,7 @@ export class LcsDiff {
852851
change.modifiedStart++;
853852
}
854853

855-
let mergedChangeArr: Array<DiffChange | null> = [null];
854+
const mergedChangeArr: Array<DiffChange | null> = [null];
856855
if (i < changes.length - 1 && this.ChangesOverlap(changes[i], changes[i + 1], mergedChangeArr)) {
857856
changes[i] = mergedChangeArr[0]!;
858857
changes.splice(i + 1, 1);
@@ -1048,7 +1047,7 @@ export class LcsDiff {
10481047
* @returns The concatenated list
10491048
*/
10501049
private ConcatenateChanges(left: DiffChange[], right: DiffChange[]): DiffChange[] {
1051-
let mergedChangeArr: DiffChange[] = [];
1050+
const mergedChangeArr: DiffChange[] = [];
10521051

10531052
if (left.length === 0 || right.length === 0) {
10541053
return (right.length > 0) ? right : left;

src/diffChange.ts renamed to src/vs/base/common/diff/diffChange.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// Updated from commit d4edb9abcc261846cabee6702715fe2914ae42cb - vscode/src/vs/base/common/diff/diffChange.ts
21
/*---------------------------------------------------------------------------------------------
32
* Copyright (c) Microsoft Corporation. All rights reserved.
43
* Licensed under the MIT License. See License.txt in the project root for license information.
@@ -7,7 +6,7 @@
76
/**
87
* Represents information about a specific difference between two sequences.
98
*/
10-
export class DiffChange {
9+
export class DiffChange {
1110

1211
/**
1312
* The position of the first element in the original sequence which

0 commit comments

Comments
 (0)