Skip to content

Commit 3988851

Browse files
committed
Make import relative instead of absolute.
Cant make it work after building otherwise: microsoft/TypeScript#15479
1 parent b7a8fa0 commit 3988851

21 files changed

+86
-84
lines changed

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ tsconfig.json
44
tsconfig.build.json
55
.editorconfig
66
knip.json
7+
example
78
node_modules/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ Steps for updating diff algorithm:
206206
* Verify with `npm run build` that all code is self-contained.
207207
* Verify with `npm run knip` that there are no unused files or exports.
208208
* Run `npm test` to run all the tests.
209-
* Update [src/example.ts] on any API changes.
209+
* Update [example/example.ts] on any API changes.
210210
* Run `npm run example` and update this README with example usage code and output.
211211
* Include VS Code version and commit hash in commit message.
212212

src/example.ts renamed to example/example.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { AdvancedLinesDiffComputer, DiffComputer, IDiffComputerOpts, ILineChange, ILinesDiffComputerOptions } from 'vscode-diff';
1+
import { AdvancedLinesDiffComputer, DiffComputer, IDiffComputerOpts, ILineChange, ILinesDiffComputerOptions } from '../dist';
22

33
let originalLines: string[] = ["hello", "original", "world"];
44
let modifiedLines: string[] = ["hello", "modified", "world", "foobar"];
55
let options: IDiffComputerOpts = {
6-
shouldPostProcessCharChanges: true,
7-
shouldIgnoreTrimWhitespace: true,
8-
shouldMakePrettyDiff: true,
9-
shouldComputeCharChanges: true,
10-
maxComputationTime: 0 // time in milliseconds, 0 => no computation limit.
6+
shouldPostProcessCharChanges: true,
7+
shouldIgnoreTrimWhitespace: true,
8+
shouldMakePrettyDiff: true,
9+
shouldComputeCharChanges: true,
10+
maxComputationTime: 0 // time in milliseconds, 0 => no computation limit.
1111
}
1212
let diffComputer = new DiffComputer(originalLines, modifiedLines, options);
1313
let lineChanges: ILineChange[] = diffComputer.computeDiff().changes;
@@ -16,9 +16,9 @@ console.log(JSON.stringify(lineChanges, null, 2));
1616

1717

1818
let advOptions: ILinesDiffComputerOptions = {
19-
ignoreTrimWhitespace: true,
20-
computeMoves: true,
21-
maxComputationTimeMs: 0
19+
ignoreTrimWhitespace: true,
20+
computeMoves: true,
21+
maxComputationTimeMs: 0
2222
}
2323
let advDiffComputer = new AdvancedLinesDiffComputer()
2424
let advLineChanges = advDiffComputer.computeDiff(originalLines, modifiedLines, advOptions).changes;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"watch": "tsc --watch",
2020
"build": "tsc --project tsconfig.build.json",
2121
"knip": "knip",
22-
"example": "ts-node src/example.ts"
22+
"example": "yarn build && ts-node ./example/example.ts"
2323
},
2424
"keywords": [
2525
"diff",

src/vs/base/common/assert.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { BugIndicatingError, onUnexpectedError } from 'vs/base/common/errors';
6+
import { BugIndicatingError, onUnexpectedError } from './errors';
77

88

99
/**

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

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';
6+
import { stringHash } from '../hash';
7+
import { Constants } from '../uint';
8+
import { DiffChange } from './diffChange';
99

1010
export class StringDiffSequence implements ISequence {
1111

src/vs/base/common/hash.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import * as strings from 'vs/base/common/strings';
6+
import * as strings from './strings';
77

88
export function doHash(obj: any, hashVal: number): number {
99
switch (typeof obj) {

src/vs/base/common/strings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { CharCode } from 'vs/base/common/charCode';
6+
import { CharCode } from './charCode';
77

88
/**
99
* Returns first index of the string that is not whitespace.

src/vs/base/test/common/diff/diff.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as assert from 'assert';
7-
import { IDiffChange, LcsDiff, StringDiffSequence } from 'vs/base/common/diff/diff';
7+
import { IDiffChange, LcsDiff, StringDiffSequence } from '../../../common/diff/diff';
88

99
function createArray<T>(length: number, value: T): T[] {
1010
const r: T[] = [];

src/vs/editor/common/core/lineRange.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { BugIndicatingError } from 'vs/base/common/errors';
7-
import { OffsetRange } from 'vs/editor/common/core/offsetRange';
8-
import { Range } from 'vs/editor/common/core/range';
6+
import { BugIndicatingError } from '../../../base/common/errors';
7+
import { OffsetRange } from './offsetRange';
8+
import { Range } from './range';
99

1010
/**
1111
* A range of lines (1-based).

src/vs/editor/common/core/offsetRange.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { BugIndicatingError } from 'vs/base/common/errors';
6+
import { BugIndicatingError } from '../../../base/common/errors';
77

88
/**
99
* A range of offsets (0-based).

src/vs/editor/common/core/range.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { IPosition, Position } from 'vs/editor/common/core/position';
6+
import { IPosition, Position } from './position';
77

88
/**
99
* A range in the editor. This interface is suitable for serialization.

src/vs/editor/common/diff/advancedLinesDiffComputer.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { Comparator, CompareResult, compareBy, equals, findLastIndex, numberComparator, reverseOrder } from 'vs/base/common/arrays';
7-
import { assertFn, checkAdjacentItems } from 'vs/base/common/assert';
8-
import { CharCode } from 'vs/base/common/charCode';
9-
import { SetMap } from 'vs/base/common/collections';
10-
import { BugIndicatingError } from 'vs/base/common/errors';
11-
import { LineRange } from 'vs/editor/common/core/lineRange';
12-
import { OffsetRange } from 'vs/editor/common/core/offsetRange';
13-
import { Position } from 'vs/editor/common/core/position';
14-
import { Range } from 'vs/editor/common/core/range';
15-
import { DateTimeout, ISequence, ITimeout, InfiniteTimeout, SequenceDiff } from 'vs/editor/common/diff/algorithms/diffAlgorithm';
16-
import { DynamicProgrammingDiffing } from 'vs/editor/common/diff/algorithms/dynamicProgrammingDiffing';
17-
import { optimizeSequenceDiffs, removeRandomLineMatches, removeRandomMatches, smoothenSequenceDiffs } from 'vs/editor/common/diff/algorithms/joinSequenceDiffs';
18-
import { MyersDiffAlgorithm } from 'vs/editor/common/diff/algorithms/myersDiffAlgorithm';
19-
import { ILinesDiffComputer, ILinesDiffComputerOptions, LineRangeMapping, LinesDiff, MovedText, RangeMapping, SimpleLineRangeMapping } from 'vs/editor/common/diff/linesDiffComputer';
6+
import { Comparator, CompareResult, compareBy, equals, findLastIndex, numberComparator, reverseOrder } from '../../../base/common/arrays';
7+
import { assertFn, checkAdjacentItems } from '../../../base/common/assert';
8+
import { CharCode } from '../../../base/common/charCode';
9+
import { SetMap } from '../../../base/common/collections';
10+
import { BugIndicatingError } from '../../../base/common/errors';
11+
import { LineRange } from '../core/lineRange';
12+
import { OffsetRange } from '../core/offsetRange';
13+
import { Position } from '../core/position';
14+
import { Range } from '../core/range';
15+
import { DateTimeout, ISequence, ITimeout, InfiniteTimeout, SequenceDiff } from '../diff/algorithms/diffAlgorithm';
16+
import { DynamicProgrammingDiffing } from '../diff/algorithms/dynamicProgrammingDiffing';
17+
import { optimizeSequenceDiffs, removeRandomLineMatches, removeRandomMatches, smoothenSequenceDiffs } from '../diff/algorithms/joinSequenceDiffs';
18+
import { MyersDiffAlgorithm } from '../diff/algorithms/myersDiffAlgorithm';
19+
import { ILinesDiffComputer, ILinesDiffComputerOptions, LineRangeMapping, LinesDiff, MovedText, RangeMapping, SimpleLineRangeMapping } from './linesDiffComputer';
2020

2121
export class AdvancedLinesDiffComputer implements ILinesDiffComputer {
2222
private readonly dynamicProgrammingDiffing = new DynamicProgrammingDiffing();

src/vs/editor/common/diff/algorithms/diffAlgorithm.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { BugIndicatingError } from 'vs/base/common/errors';
7-
import { OffsetRange } from 'vs/editor/common/core/offsetRange';
6+
import { BugIndicatingError } from '../../../../base/common/errors';
7+
import { OffsetRange } from '../../core/offsetRange';
88

99
/**
1010
* Represents a synchronous diff algorithm. Should be executed in a worker.

src/vs/editor/common/diff/algorithms/dynamicProgrammingDiffing.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { OffsetRange } from 'vs/editor/common/core/offsetRange';
7-
import { IDiffAlgorithm, SequenceDiff, ISequence, ITimeout, InfiniteTimeout, DiffAlgorithmResult } from 'vs/editor/common/diff/algorithms/diffAlgorithm';
8-
import { Array2D } from 'vs/editor/common/diff/algorithms/utils';
6+
import { OffsetRange } from '../../core/offsetRange';
7+
import { DiffAlgorithmResult, IDiffAlgorithm, ISequence, ITimeout, InfiniteTimeout, SequenceDiff } from './diffAlgorithm';
8+
import { Array2D } from './utils';
99

1010
/**
1111
* A O(MN) diffing algorithm that supports a score function.

src/vs/editor/common/diff/algorithms/joinSequenceDiffs.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { OffsetRange } from 'vs/editor/common/core/offsetRange';
7-
import { ISequence, SequenceDiff } from 'vs/editor/common/diff/algorithms/diffAlgorithm';
8-
import { LineSequence, LinesSliceCharSequence } from 'vs/editor/common/diff/advancedLinesDiffComputer';
6+
import { OffsetRange } from '../../core/offsetRange';
7+
import { LineSequence, LinesSliceCharSequence } from '../advancedLinesDiffComputer';
8+
import { ISequence, SequenceDiff } from '../algorithms/diffAlgorithm';
99

1010
export function optimizeSequenceDiffs(sequence1: ISequence, sequence2: ISequence, sequenceDiffs: SequenceDiff[]): SequenceDiff[] {
1111
let result = sequenceDiffs;

src/vs/editor/common/diff/algorithms/myersDiffAlgorithm.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { OffsetRange } from 'vs/editor/common/core/offsetRange';
7-
import { DiffAlgorithmResult, IDiffAlgorithm, ISequence, ITimeout, InfiniteTimeout, SequenceDiff } from 'vs/editor/common/diff/algorithms/diffAlgorithm';
6+
import { OffsetRange } from '../../core/offsetRange';
7+
import { DiffAlgorithmResult, IDiffAlgorithm, ISequence, ITimeout, InfiniteTimeout, SequenceDiff } from '../algorithms/diffAlgorithm';
88

99
/**
1010
* An O(ND) diff algorithm that has a quadratic space worst-case complexity.

src/vs/editor/common/diff/legacyLinesDiffComputer.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { CharCode } from 'vs/base/common/charCode';
7-
import { IDiffChange, ISequence, LcsDiff, IDiffResult } from 'vs/base/common/diff/diff';
8-
import { ILinesDiffComputer, ILinesDiffComputerOptions, RangeMapping, LineRangeMapping, LinesDiff } from 'vs/editor/common/diff/linesDiffComputer';
9-
import * as strings from 'vs/base/common/strings';
10-
import { Range } from 'vs/editor/common/core/range';
11-
import { assertFn, checkAdjacentItems } from 'vs/base/common/assert';
12-
import { LineRange } from 'vs/editor/common/core/lineRange';
6+
import { assertFn, checkAdjacentItems } from "../../../base/common/assert";
7+
import { CharCode } from "../../../base/common/charCode";
8+
import { IDiffChange, IDiffResult, ISequence, LcsDiff } from "../../../base/common/diff/diff";
9+
import * as strings from "../../../base/common/strings";
10+
import { LineRange } from "../core/lineRange";
11+
import { Range } from "../core/range";
12+
import { ILinesDiffComputer, ILinesDiffComputerOptions, LineRangeMapping, LinesDiff, RangeMapping } from "./linesDiffComputer";
1313

1414
const MINIMUM_MATCHING_CHARACTER_LENGTH = 3;
1515

src/vs/editor/common/diff/linesDiffComputer.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { LineRange } from 'vs/editor/common/core/lineRange';
7-
import { Range } from 'vs/editor/common/core/range';
6+
import { LineRange } from "../core/lineRange";
7+
import { Range } from "../core/range";
8+
89

910
export interface ILinesDiffComputer {
1011
computeDiff(originalLines: string[], modifiedLines: string[], options: ILinesDiffComputerOptions): LinesDiff;

tsconfig.build.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{
22
"extends": "./tsconfig.json",
3-
"exclude": ["src/**/*.test.ts", "src/example.ts"]
4-
}
3+
"exclude": [
4+
"src/**/*.test.ts"
5+
]
6+
}

tsconfig.json

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
11
{
2-
"compilerOptions": {
3-
"target": "es2021",
4-
"lib": [
5-
"es2021",
6-
"DOM"
7-
],
8-
"module": "commonjs",
9-
"declaration": true,
10-
"outDir": "./dist",
11-
"strict": true,
12-
"useUnknownInCatchVariables": false,
13-
"baseUrl": "./src",
14-
"paths": {
15-
"vscode-diff": ["./"],
16-
}
17-
},
18-
"ts-node": {
19-
"require": ["tsconfig-paths/register"]
20-
},
21-
"include": [
22-
"src/**/*"
23-
],
24-
"exclude": [
25-
"node_modules"
26-
]
27-
}
2+
"compilerOptions": {
3+
"target": "es2021",
4+
"lib": [
5+
"es2021",
6+
"DOM"
7+
],
8+
"module": "commonjs",
9+
"declaration": true,
10+
"outDir": "./dist",
11+
"strict": true,
12+
"useUnknownInCatchVariables": false,
13+
},
14+
"ts-node": {
15+
"require": [
16+
"tsconfig-paths/register"
17+
]
18+
},
19+
"include": [
20+
"src/**/*",
21+
],
22+
"exclude": [
23+
"node_modules"
24+
]
25+
}

0 commit comments

Comments
 (0)