Skip to content

Commit

Permalink
Make import relative instead of absolute.
Browse files Browse the repository at this point in the history
Cant make it work after building otherwise:
microsoft/TypeScript#15479
  • Loading branch information
micnil committed Sep 19, 2023
1 parent b7a8fa0 commit 3988851
Show file tree
Hide file tree
Showing 21 changed files with 86 additions and 84 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ tsconfig.json
tsconfig.build.json
.editorconfig
knip.json
example
node_modules/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ Steps for updating diff algorithm:
* Verify with `npm run build` that all code is self-contained.
* Verify with `npm run knip` that there are no unused files or exports.
* Run `npm test` to run all the tests.
* Update [src/example.ts] on any API changes.
* Update [example/example.ts] on any API changes.
* Run `npm run example` and update this README with example usage code and output.
* Include VS Code version and commit hash in commit message.

Expand Down
18 changes: 9 additions & 9 deletions src/example.ts → example/example.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { AdvancedLinesDiffComputer, DiffComputer, IDiffComputerOpts, ILineChange, ILinesDiffComputerOptions } from 'vscode-diff';
import { AdvancedLinesDiffComputer, DiffComputer, IDiffComputerOpts, ILineChange, ILinesDiffComputerOptions } from '../dist';

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


let advOptions: ILinesDiffComputerOptions = {
ignoreTrimWhitespace: true,
computeMoves: true,
maxComputationTimeMs: 0
ignoreTrimWhitespace: true,
computeMoves: true,
maxComputationTimeMs: 0
}
let advDiffComputer = new AdvancedLinesDiffComputer()
let advLineChanges = advDiffComputer.computeDiff(originalLines, modifiedLines, advOptions).changes;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"watch": "tsc --watch",
"build": "tsc --project tsconfig.build.json",
"knip": "knip",
"example": "ts-node src/example.ts"
"example": "yarn build && ts-node ./example/example.ts"
},
"keywords": [
"diff",
Expand Down
2 changes: 1 addition & 1 deletion src/vs/base/common/assert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { BugIndicatingError, onUnexpectedError } from 'vs/base/common/errors';
import { BugIndicatingError, onUnexpectedError } from './errors';


/**
Expand Down
6 changes: 3 additions & 3 deletions src/vs/base/common/diff/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { DiffChange } from 'vs/base/common/diff/diffChange';
import { stringHash } from 'vs/base/common/hash';
import { Constants } from 'vs/base/common/uint';
import { stringHash } from '../hash';
import { Constants } from '../uint';
import { DiffChange } from './diffChange';

export class StringDiffSequence implements ISequence {

Expand Down
2 changes: 1 addition & 1 deletion src/vs/base/common/hash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as strings from 'vs/base/common/strings';
import * as strings from './strings';

export function doHash(obj: any, hashVal: number): number {
switch (typeof obj) {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/base/common/strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { CharCode } from 'vs/base/common/charCode';
import { CharCode } from './charCode';

/**
* Returns first index of the string that is not whitespace.
Expand Down
2 changes: 1 addition & 1 deletion src/vs/base/test/common/diff/diff.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import * as assert from 'assert';
import { IDiffChange, LcsDiff, StringDiffSequence } from 'vs/base/common/diff/diff';
import { IDiffChange, LcsDiff, StringDiffSequence } from '../../../common/diff/diff';

function createArray<T>(length: number, value: T): T[] {
const r: T[] = [];
Expand Down
6 changes: 3 additions & 3 deletions src/vs/editor/common/core/lineRange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { BugIndicatingError } from 'vs/base/common/errors';
import { OffsetRange } from 'vs/editor/common/core/offsetRange';
import { Range } from 'vs/editor/common/core/range';
import { BugIndicatingError } from '../../../base/common/errors';
import { OffsetRange } from './offsetRange';
import { Range } from './range';

/**
* A range of lines (1-based).
Expand Down
2 changes: 1 addition & 1 deletion src/vs/editor/common/core/offsetRange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { BugIndicatingError } from 'vs/base/common/errors';
import { BugIndicatingError } from '../../../base/common/errors';

/**
* A range of offsets (0-based).
Expand Down
2 changes: 1 addition & 1 deletion src/vs/editor/common/core/range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

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

/**
* A range in the editor. This interface is suitable for serialization.
Expand Down
28 changes: 14 additions & 14 deletions src/vs/editor/common/diff/advancedLinesDiffComputer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { Comparator, CompareResult, compareBy, equals, findLastIndex, numberComparator, reverseOrder } from 'vs/base/common/arrays';
import { assertFn, checkAdjacentItems } from 'vs/base/common/assert';
import { CharCode } from 'vs/base/common/charCode';
import { SetMap } from 'vs/base/common/collections';
import { BugIndicatingError } from 'vs/base/common/errors';
import { LineRange } from 'vs/editor/common/core/lineRange';
import { OffsetRange } from 'vs/editor/common/core/offsetRange';
import { Position } from 'vs/editor/common/core/position';
import { Range } from 'vs/editor/common/core/range';
import { DateTimeout, ISequence, ITimeout, InfiniteTimeout, SequenceDiff } from 'vs/editor/common/diff/algorithms/diffAlgorithm';
import { DynamicProgrammingDiffing } from 'vs/editor/common/diff/algorithms/dynamicProgrammingDiffing';
import { optimizeSequenceDiffs, removeRandomLineMatches, removeRandomMatches, smoothenSequenceDiffs } from 'vs/editor/common/diff/algorithms/joinSequenceDiffs';
import { MyersDiffAlgorithm } from 'vs/editor/common/diff/algorithms/myersDiffAlgorithm';
import { ILinesDiffComputer, ILinesDiffComputerOptions, LineRangeMapping, LinesDiff, MovedText, RangeMapping, SimpleLineRangeMapping } from 'vs/editor/common/diff/linesDiffComputer';
import { Comparator, CompareResult, compareBy, equals, findLastIndex, numberComparator, reverseOrder } from '../../../base/common/arrays';
import { assertFn, checkAdjacentItems } from '../../../base/common/assert';
import { CharCode } from '../../../base/common/charCode';
import { SetMap } from '../../../base/common/collections';
import { BugIndicatingError } from '../../../base/common/errors';
import { LineRange } from '../core/lineRange';
import { OffsetRange } from '../core/offsetRange';
import { Position } from '../core/position';
import { Range } from '../core/range';
import { DateTimeout, ISequence, ITimeout, InfiniteTimeout, SequenceDiff } from '../diff/algorithms/diffAlgorithm';
import { DynamicProgrammingDiffing } from '../diff/algorithms/dynamicProgrammingDiffing';
import { optimizeSequenceDiffs, removeRandomLineMatches, removeRandomMatches, smoothenSequenceDiffs } from '../diff/algorithms/joinSequenceDiffs';
import { MyersDiffAlgorithm } from '../diff/algorithms/myersDiffAlgorithm';
import { ILinesDiffComputer, ILinesDiffComputerOptions, LineRangeMapping, LinesDiff, MovedText, RangeMapping, SimpleLineRangeMapping } from './linesDiffComputer';

export class AdvancedLinesDiffComputer implements ILinesDiffComputer {
private readonly dynamicProgrammingDiffing = new DynamicProgrammingDiffing();
Expand Down
4 changes: 2 additions & 2 deletions src/vs/editor/common/diff/algorithms/diffAlgorithm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { BugIndicatingError } from 'vs/base/common/errors';
import { OffsetRange } from 'vs/editor/common/core/offsetRange';
import { BugIndicatingError } from '../../../../base/common/errors';
import { OffsetRange } from '../../core/offsetRange';

/**
* Represents a synchronous diff algorithm. Should be executed in a worker.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

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

/**
* A O(MN) diffing algorithm that supports a score function.
Expand Down
6 changes: 3 additions & 3 deletions src/vs/editor/common/diff/algorithms/joinSequenceDiffs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { OffsetRange } from 'vs/editor/common/core/offsetRange';
import { ISequence, SequenceDiff } from 'vs/editor/common/diff/algorithms/diffAlgorithm';
import { LineSequence, LinesSliceCharSequence } from 'vs/editor/common/diff/advancedLinesDiffComputer';
import { OffsetRange } from '../../core/offsetRange';
import { LineSequence, LinesSliceCharSequence } from '../advancedLinesDiffComputer';
import { ISequence, SequenceDiff } from '../algorithms/diffAlgorithm';

export function optimizeSequenceDiffs(sequence1: ISequence, sequence2: ISequence, sequenceDiffs: SequenceDiff[]): SequenceDiff[] {
let result = sequenceDiffs;
Expand Down
4 changes: 2 additions & 2 deletions src/vs/editor/common/diff/algorithms/myersDiffAlgorithm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

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

/**
* An O(ND) diff algorithm that has a quadratic space worst-case complexity.
Expand Down
14 changes: 7 additions & 7 deletions src/vs/editor/common/diff/legacyLinesDiffComputer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { CharCode } from 'vs/base/common/charCode';
import { IDiffChange, ISequence, LcsDiff, IDiffResult } from 'vs/base/common/diff/diff';
import { ILinesDiffComputer, ILinesDiffComputerOptions, RangeMapping, LineRangeMapping, LinesDiff } from 'vs/editor/common/diff/linesDiffComputer';
import * as strings from 'vs/base/common/strings';
import { Range } from 'vs/editor/common/core/range';
import { assertFn, checkAdjacentItems } from 'vs/base/common/assert';
import { LineRange } from 'vs/editor/common/core/lineRange';
import { assertFn, checkAdjacentItems } from "../../../base/common/assert";
import { CharCode } from "../../../base/common/charCode";
import { IDiffChange, IDiffResult, ISequence, LcsDiff } from "../../../base/common/diff/diff";
import * as strings from "../../../base/common/strings";
import { LineRange } from "../core/lineRange";
import { Range } from "../core/range";
import { ILinesDiffComputer, ILinesDiffComputerOptions, LineRangeMapping, LinesDiff, RangeMapping } from "./linesDiffComputer";

const MINIMUM_MATCHING_CHARACTER_LENGTH = 3;

Expand Down
5 changes: 3 additions & 2 deletions src/vs/editor/common/diff/linesDiffComputer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { LineRange } from 'vs/editor/common/core/lineRange';
import { Range } from 'vs/editor/common/core/range';
import { LineRange } from "../core/lineRange";
import { Range } from "../core/range";


export interface ILinesDiffComputer {
computeDiff(originalLines: string[], modifiedLines: string[], options: ILinesDiffComputerOptions): LinesDiff;
Expand Down
6 changes: 4 additions & 2 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"extends": "./tsconfig.json",
"exclude": ["src/**/*.test.ts", "src/example.ts"]
}
"exclude": [
"src/**/*.test.ts"
]
}
50 changes: 24 additions & 26 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
{
"compilerOptions": {
"target": "es2021",
"lib": [
"es2021",
"DOM"
],
"module": "commonjs",
"declaration": true,
"outDir": "./dist",
"strict": true,
"useUnknownInCatchVariables": false,
"baseUrl": "./src",
"paths": {
"vscode-diff": ["./"],
}
},
"ts-node": {
"require": ["tsconfig-paths/register"]
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules"
]
}
"compilerOptions": {
"target": "es2021",
"lib": [
"es2021",
"DOM"
],
"module": "commonjs",
"declaration": true,
"outDir": "./dist",
"strict": true,
"useUnknownInCatchVariables": false,
},
"ts-node": {
"require": [
"tsconfig-paths/register"
]
},
"include": [
"src/**/*",
],
"exclude": [
"node_modules"
]
}

0 comments on commit 3988851

Please sign in to comment.