Skip to content

Commit f8ba32b

Browse files
authored
Merge pull request #2448 from Particular/john/update-diff
2 parents 90863f9 + 28b5710 commit f8ba32b

File tree

3 files changed

+17
-26
lines changed

3 files changed

+17
-26
lines changed

src/Frontend/package-lock.json

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

src/Frontend/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"bootstrap": "^5.3.5",
2929
"bootstrap-icons": "^1.13.1",
3030
"codemirror": "^6.0.1",
31-
"diff": "^7.0.0",
31+
"diff": "^8.0.2",
3232
"hex-to-css-filter": "^6.0.0",
3333
"lodash.debounce": "^4.0.8",
3434
"lodash.throttle": "^4.0.8",
@@ -54,7 +54,6 @@
5454
"@testing-library/vue": "^8.1.0",
5555
"@tsconfig/node18": "^18.2.4",
5656
"@types/bootstrap": "^5.2.10",
57-
"@types/diff": "^7.0.2",
5857
"@types/lodash": "^4.17.17",
5958
"@types/node": "^22.15.29",
6059
"@vitejs/plugin-vue": "^5.2.4",

src/Frontend/src/components/messages/DiffContent.vue

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
22
import { ref, computed, watch } from "vue";
3-
import * as diff from "diff";
3+
import { diffLines, diffWords, diffWordsWithSpace, diffChars, diffTrimmedLines, diffSentences, diffCss } from "diff";
44
55
// Types needed for the diff viewer
66
interface DiffChange {
@@ -67,7 +67,7 @@ const props = withDefaults(defineProps<Props>(), {
6767
6868
// Component state
6969
const lineInformation = ref<LineInformation[]>([]);
70-
const diffLines = ref<number[]>([]);
70+
const diffLineIndexes = ref<number[]>([]);
7171
const expandedBlocks = ref<number[]>([]);
7272
7373
// Compute diff when inputs change
@@ -92,34 +92,34 @@ const computeDiff = (): void => {
9292
});
9393
9494
lineInformation.value = result;
95-
diffLines.value = [];
95+
diffLineIndexes.value = [];
9696
return;
9797
}
9898
9999
// Generate diff based on selected method
100100
let diffOutput: DiffChange[];
101101
switch (compareMethod) {
102102
case "diffChars":
103-
diffOutput = diff.diffChars(oldValue, newValue);
103+
diffOutput = diffChars(oldValue, newValue);
104104
break;
105105
case "diffWords":
106-
diffOutput = diff.diffWords(oldValue, newValue);
106+
diffOutput = diffWords(oldValue, newValue);
107107
break;
108108
case "diffWordsWithSpace":
109-
diffOutput = diff.diffWordsWithSpace(oldValue, newValue);
109+
diffOutput = diffWordsWithSpace(oldValue, newValue);
110110
break;
111111
case "diffTrimmedLines":
112-
diffOutput = diff.diffTrimmedLines(oldValue, newValue);
112+
diffOutput = diffTrimmedLines(oldValue, newValue);
113113
break;
114114
case "diffSentences":
115-
diffOutput = diff.diffSentences(oldValue, newValue);
115+
diffOutput = diffSentences(oldValue, newValue);
116116
break;
117117
case "diffCss":
118-
diffOutput = diff.diffCss(oldValue, newValue);
118+
diffOutput = diffCss(oldValue, newValue);
119119
break;
120120
case "diffLines":
121121
default:
122-
diffOutput = diff.diffLines(oldValue, newValue);
122+
diffOutput = diffLines(oldValue, newValue);
123123
break;
124124
}
125125
@@ -170,7 +170,7 @@ const computeDiff = (): void => {
170170
});
171171
172172
lineInformation.value = result;
173-
diffLines.value = diffLinesArray;
173+
diffLineIndexes.value = diffLinesArray;
174174
175175
// Reset expanded blocks when diff changes
176176
expandedBlocks.value = [];
@@ -194,7 +194,7 @@ const renderDiff = computed<DiffItem[]>(() => {
194194
const result: DiffItem[] = [];
195195
196196
// Create a mutable copy of diffLines for manipulation in the loop
197-
const currentDiffLines = [...diffLines.value];
197+
const currentDiffLines = [...diffLineIndexes.value];
198198
199199
lineInformation.value.forEach((line, i) => {
200200
const diffBlockStart = currentDiffLines[0];

0 commit comments

Comments
 (0)