@ww_nero/mini-cli 1.0.72 → 1.0.73
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.
- package/package.json +1 -1
- package/src/chat.js +13 -7
package/package.json
CHANGED
package/src/chat.js
CHANGED
|
@@ -103,14 +103,20 @@ const formatReplaceOutput = (result) => {
|
|
|
103
103
|
const lines = [];
|
|
104
104
|
|
|
105
105
|
const searchLines = searchContent.split('\n');
|
|
106
|
-
searchLines.forEach((line) => {
|
|
107
|
-
lines.push(chalk.red(`-${line}`));
|
|
108
|
-
});
|
|
109
|
-
|
|
110
106
|
const replaceLines = replaceContent.split('\n');
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
107
|
+
const maxLinesPerSide = 20;
|
|
108
|
+
const appendLimitedLines = (list, prefix, colorizer) => {
|
|
109
|
+
const limit = Math.min(list.length, maxLinesPerSide);
|
|
110
|
+
for (let i = 0; i < limit; i += 1) {
|
|
111
|
+
lines.push(colorizer(`${prefix}${list[i]}`));
|
|
112
|
+
}
|
|
113
|
+
if (list.length > maxLinesPerSide) {
|
|
114
|
+
lines.push(colorizer(`${prefix} ...(更多代码)`));
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
appendLimitedLines(searchLines, '-', chalk.red);
|
|
119
|
+
appendLimitedLines(replaceLines, '+', chalk.green);
|
|
114
120
|
|
|
115
121
|
return lines.join('\n');
|
|
116
122
|
};
|