diff.ts ×20

Frontier kind: Code frontier

unlabeled · c_2b59b95789cb

96 tests · 6061 LOC · 31 files · introduces 0 tests · 58 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
20 ranges58 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
898 ranges6061 lines · 31 files · Browse complete extent
All tests (intent)
96 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 58 introduced LOC across 20 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/base/common/diff/diff.ts 58 introduced LOC · 20 ranges

Open complete file

830 // Shift all the changes down first
831 for (let i = 0; i < changes.length; i++) {
832 > const change = changes[i]; diff.ts
833 > const originalStop = (i < changes.length - 1) ? changes[i + 1].originalStart : this._originalElementsOrHash.length;
834 > const modifiedStop = (i < changes.length - 1) ? changes[i + 1].modifiedStart : this._modifiedElementsOrHash.length;
835 > const checkOriginal = change.originalLength > 0;
836 > const checkModified = change.modifiedLength > 0;
837 >
838 > while (
839 > change.originalStart + change.originalLength < originalStop
840 && change.modifiedStart + change.modifiedLength < modifiedStop
841 && (!checkOriginal || this.OriginalElementsAreEqual(change.originalStart, change.originalStart + change.originalLength))
842 && (!checkModified || this.ModifiedElementsAreEqual(change.modifiedStart, change.modifiedStart + change.modifiedLength))
843 > ) { diff.ts
844 const startStrictEqual = this.ElementsAreStrictEqual(change.originalStart, change.modifiedStart);
845 const endStrictEqual = this.ElementsAreStrictEqual(change.originalStart + change.originalLength, change.modifiedStart + change.modifiedLength);
851 change.modifiedStart++;
852 }
853 > diff.ts
854 > const mergedChangeArr: Array<DiffChange | null> = [null];
855 > if (i < changes.length - 1 && this.ChangesOverlap(changes[i], changes[i + 1], mergedChangeArr)) {
856 changes[i] = mergedChangeArr[0]!;
857 changes.splice(i + 1, 1);
859 continue;
860 }
861 > } diff.ts
862
863 // Shift changes back up until we hit empty or whitespace-only lines
864 for (let i = changes.length - 1; i >= 0; i--) {
865 > const change = changes[i]; diff.ts
866 >
867 > let originalStop = 0;
868 > let modifiedStop = 0;
869 > if (i > 0) {
870 const prevChange = changes[i - 1];
871 originalStop = prevChange.originalStart + prevChange.originalLength;
872 modifiedStop = prevChange.modifiedStart + prevChange.modifiedLength;
873 }
874 > diff.ts
875 > const checkOriginal = change.originalLength > 0;
876 > const checkModified = change.modifiedLength > 0;
877 >
878 > let bestDelta = 0;
879 > let bestScore = this._boundaryScore(change.originalStart, change.originalLength, change.modifiedStart, change.modifiedLength);
880 >
881 > for (let delta = 1; ; delta++) {
882 > const originalStart = change.originalStart - delta;
883 > const modifiedStart = change.modifiedStart - delta;
884 >
885 > if (originalStart < originalStop || modifiedStart < modifiedStop) {
886 break;
887 }
888
889 > if (checkOriginal && !this.OriginalElementsAreEqual(originalStart, originalStart + change.originalLength)) { diff.ts
890 break;
891 }
892
893 > if (checkModified && !this.ModifiedElementsAreEqual(modifiedStart, modifiedStart + change.modifiedLength)) { diff.ts
894 break;
895 }
896
897 const touchingPreviousChange = (originalStart === originalStop && modifiedStart === modifiedStop);
898 > const score = ( diff.ts
899 > (touchingPreviousChange ? 5 : 0)
900 > + this._boundaryScore(originalStart, change.originalLength, modifiedStart, change.modifiedLength)
901 > );
902 >
903 > if (score > bestScore) {
904 bestScore = score;
905 bestDelta = delta;
906 }
907 > } diff.ts
908 >
909 > change.originalStart -= bestDelta;
910 > change.modifiedStart -= bestDelta;
911 >
912 > const mergedChangeArr: Array<DiffChange | null> = [null];
913 > if (i > 0 && this.ChangesOverlap(changes[i - 1], changes[i], mergedChangeArr)) {
914 changes[i - 1] = mergedChangeArr[0]!;
915 changes.splice(i, 1);
917 continue;
918 }
919 > } diff.ts
920
921 // There could be multiple longest common substrings.
995
996 private _OriginalIsBoundary(index: number): boolean {
997 > if (index <= 0 || index >= this._originalElementsOrHash.length - 1) { diff.ts
998 return true;
999 }
1000 return (this._hasStrings && /^\s*$/.test(this._originalStringElements[index]));
1001 > } diff.ts
1002
1003 private _OriginalRegionIsBoundary(originalStart: number, originalLength: number): boolean {
1004 > if (this._OriginalIsBoundary(originalStart) || this._OriginalIsBoundary(originalStart - 1)) { diff.ts
1005 return true;
1006 }
1012 }
1013 return false;
1014 > } diff.ts
1015
1016 private _ModifiedIsBoundary(index: number): boolean {
1017 > if (index <= 0 || index >= this._modifiedElementsOrHash.length - 1) { diff.ts
1018 return true;
1019 }
1020 return (this._hasStrings && /^\s*$/.test(this._modifiedStringElements[index]));
1021 > } diff.ts
1022
1023 private _ModifiedRegionIsBoundary(modifiedStart: number, modifiedLength: number): boolean {
1024 > if (this._ModifiedIsBoundary(modifiedStart) || this._ModifiedIsBoundary(modifiedStart - 1)) { diff.ts
1025 return true;
1026 }
1032 }
1033 return false;
1034 > } diff.ts
1035
1036 private _boundaryScore(originalStart: number, originalLength: number, modifiedStart: number, modifiedLength: number): number {
1037 > const originalScore = (this._OriginalRegionIsBoundary(originalStart, originalLength) ? 1 : 0); diff.ts
1038 > const modifiedScore = (this._ModifiedRegionIsBoundary(modifiedStart, modifiedLength) ? 1 : 0);
1039 > return (originalScore + modifiedScore);
1040 > }
1041
1042 /**