diffwatch 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -52,7 +52,7 @@ function formatDiffWithDiff2Html(diffString, searchTerm) {
|
|
|
52
52
|
$('.d2h-diff-tbody tr').each((_, row) => {
|
|
53
53
|
const $row = $(row);
|
|
54
54
|
if ($row.find('.d2h-code-line').length > 0) {
|
|
55
|
-
const $
|
|
55
|
+
const $lineNumberCell = $row.find('td.d2h-code-linenumber');
|
|
56
56
|
const isAdded = $row.find('td.d2h-ins').length > 0;
|
|
57
57
|
const isDeleted = $row.find('td.d2h-del').length > 0;
|
|
58
58
|
const $lineContent = $row.find('.d2h-code-line-ctn');
|
|
@@ -60,6 +60,10 @@ function formatDiffWithDiff2Html(diffString, searchTerm) {
|
|
|
60
60
|
const $lineWrapper = $row.find('.d2h-code-line');
|
|
61
61
|
let prefix = '';
|
|
62
62
|
let content = '';
|
|
63
|
+
let lineNumber = '';
|
|
64
|
+
if ($lineNumberCell.length > 0) {
|
|
65
|
+
lineNumber = $lineNumberCell.text().trim();
|
|
66
|
+
}
|
|
63
67
|
if ($linePrefix.length > 0) {
|
|
64
68
|
prefix = $linePrefix.text();
|
|
65
69
|
}
|
|
@@ -70,6 +74,8 @@ function formatDiffWithDiff2Html(diffString, searchTerm) {
|
|
|
70
74
|
content = $lineWrapper.text().trim();
|
|
71
75
|
}
|
|
72
76
|
let fullLine = prefix + content;
|
|
77
|
+
// Add line number with proper formatting
|
|
78
|
+
const formattedLineNumber = lineNumber ? `${lineNumber}: ` : ' ';
|
|
73
79
|
// Highlight search term if present
|
|
74
80
|
if (searchTerm && fullLine.toLowerCase().includes(searchTerm.toLowerCase())) {
|
|
75
81
|
const regex = new RegExp(`(${searchTerm.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')})`, 'gi');
|
|
@@ -79,13 +85,13 @@ function formatDiffWithDiff2Html(diffString, searchTerm) {
|
|
|
79
85
|
fullLine = fullLine.replace(regex, `\x1b[43m\x1b[30m$1\x1b[0m\x1b[${baseColor}m`);
|
|
80
86
|
}
|
|
81
87
|
if (isAdded) {
|
|
82
|
-
blessedText += `\x1b[32m${fullLine}\x1b[0m\n`;
|
|
88
|
+
blessedText += `\x1b[90m${formattedLineNumber}\x1b[0m\x1b[32m${fullLine}\x1b[0m\n`;
|
|
83
89
|
}
|
|
84
90
|
else if (isDeleted) {
|
|
85
|
-
blessedText += `\x1b[31m${fullLine}\x1b[0m\n`;
|
|
91
|
+
blessedText += `\x1b[90m${formattedLineNumber}\x1b[0m\x1b[31m${fullLine}\x1b[0m\n`;
|
|
86
92
|
}
|
|
87
93
|
else {
|
|
88
|
-
blessedText += `\x1b[37m${fullLine}\x1b[0m\n`;
|
|
94
|
+
blessedText += `\x1b[90m${formattedLineNumber}\x1b[0m\x1b[37m${fullLine}\x1b[0m\n`;
|
|
89
95
|
}
|
|
90
96
|
}
|
|
91
97
|
if ($row.find('.d2h-info').length > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff-formatter.js","sourceRoot":"","sources":["../../src/utils/diff-formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,
|
|
1
|
+
{"version":3,"file":"diff-formatter.js","sourceRoot":"","sources":["../../src/utils/diff-formatter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,0DA6EC;AAhFD,iDAAmC;AACnC,MAAM,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AAEvC,SAAgB,uBAAuB,CAAC,UAAkB,EAAE,UAAmB;IAC7E,IAAI,CAAC,UAAU,IAAI,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QAC5C,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,UAAU,EAAE;YAC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AAQ,WAAW,CAAC;gBACrF,CAAC;YACJ,CAAC;YAEH,IAAI,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACtC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;gBACtD,WAAW,IAAI,WAAW,QAAQ,WAAW,CAAC;YAChD,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,WAAW,CAAC,IAAI,EAAE,CAAC;IAC5B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,0BAA0B,KAAK,EAAE,CAAC;IAC3C,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -18,30 +18,37 @@ export function formatDiffWithDiff2Html(diffString: string, searchTerm?: string)
|
|
|
18
18
|
|
|
19
19
|
let blessedText = '';
|
|
20
20
|
|
|
21
|
-
$('.d2h-diff-tbody tr').each((_, row) => {
|
|
22
|
-
const $row = $(row);
|
|
23
|
-
|
|
24
|
-
if ($row.find('.d2h-code-line').length > 0) {
|
|
25
|
-
const $
|
|
26
|
-
const isAdded = $row.find('td.d2h-ins').length > 0;
|
|
27
|
-
const isDeleted = $row.find('td.d2h-del').length > 0;
|
|
28
|
-
const $lineContent = $row.find('.d2h-code-line-ctn');
|
|
29
|
-
const $linePrefix = $row.find('.d2h-code-line-prefix');
|
|
30
|
-
const $lineWrapper = $row.find('.d2h-code-line');
|
|
31
|
-
|
|
32
|
-
let prefix = '';
|
|
33
|
-
let content = '';
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
21
|
+
$('.d2h-diff-tbody tr').each((_, row) => {
|
|
22
|
+
const $row = $(row);
|
|
23
|
+
|
|
24
|
+
if ($row.find('.d2h-code-line').length > 0) {
|
|
25
|
+
const $lineNumberCell = $row.find('td.d2h-code-linenumber');
|
|
26
|
+
const isAdded = $row.find('td.d2h-ins').length > 0;
|
|
27
|
+
const isDeleted = $row.find('td.d2h-del').length > 0;
|
|
28
|
+
const $lineContent = $row.find('.d2h-code-line-ctn');
|
|
29
|
+
const $linePrefix = $row.find('.d2h-code-line-prefix');
|
|
30
|
+
const $lineWrapper = $row.find('.d2h-code-line');
|
|
31
|
+
|
|
32
|
+
let prefix = '';
|
|
33
|
+
let content = '';
|
|
34
|
+
let lineNumber = '';
|
|
35
|
+
|
|
36
|
+
if ($lineNumberCell.length > 0) {
|
|
37
|
+
lineNumber = $lineNumberCell.text().trim();
|
|
38
|
+
}
|
|
39
|
+
if ($linePrefix.length > 0) {
|
|
40
|
+
prefix = $linePrefix.text();
|
|
41
|
+
}
|
|
42
|
+
if ($lineContent.length > 0) {
|
|
43
|
+
content = $lineContent.text();
|
|
44
|
+
} else {
|
|
45
|
+
content = $lineWrapper.text().trim();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
let fullLine = prefix + content;
|
|
49
|
+
|
|
50
|
+
// Add line number with proper formatting
|
|
51
|
+
const formattedLineNumber = lineNumber ? `${lineNumber}: ` : ' ';
|
|
45
52
|
|
|
46
53
|
// Highlight search term if present
|
|
47
54
|
if (searchTerm && fullLine.toLowerCase().includes(searchTerm.toLowerCase())) {
|
|
@@ -52,13 +59,13 @@ export function formatDiffWithDiff2Html(diffString: string, searchTerm?: string)
|
|
|
52
59
|
fullLine = fullLine.replace(regex, `\x1b[43m\x1b[30m$1\x1b[0m\x1b[${baseColor}m`);
|
|
53
60
|
}
|
|
54
61
|
|
|
55
|
-
if (isAdded) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
if (isAdded) {
|
|
63
|
+
blessedText += `\x1b[90m${formattedLineNumber}\x1b[0m\x1b[32m${fullLine}\x1b[0m\n`;
|
|
64
|
+
} else if (isDeleted) {
|
|
65
|
+
blessedText += `\x1b[90m${formattedLineNumber}\x1b[0m\x1b[31m${fullLine}\x1b[0m\n`;
|
|
66
|
+
} else {
|
|
67
|
+
blessedText += `\x1b[90m${formattedLineNumber}\x1b[0m\x1b[37m${fullLine}\x1b[0m\n`;
|
|
68
|
+
}
|
|
62
69
|
}
|
|
63
70
|
|
|
64
71
|
if ($row.find('.d2h-info').length > 0) {
|