opencode-gbk-tools 0.1.19 → 0.1.22
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/dist/opencode-tools/gbk_edit.js +29 -30
- package/dist/opencode-tools/gbk_read.js +3 -3
- package/dist/opencode-tools/gbk_search.js +3 -3
- package/dist/opencode-tools/gbk_write.js +2 -2
- package/dist/opencode-tools/text_edit.js +4 -8
- package/dist/plugin/index.js +35 -40
- package/dist/plugins/opencode-gbk-tools.js +35 -40
- package/dist/release-manifest.json +2 -2
- package/package.json +1 -1
|
@@ -16307,17 +16307,13 @@ async function assertPathAllowed(filePath, context, allowExternal = false) {
|
|
|
16307
16307
|
var STREAMING_FILE_SIZE_THRESHOLD_BYTES = 1024 * 1024;
|
|
16308
16308
|
var STREAM_READ_CHUNK_SIZE_BYTES = 1024 * 1024;
|
|
16309
16309
|
var gbkLineIndexCache = /* @__PURE__ */ new Map();
|
|
16310
|
-
var ANSI_RED = "\x1B[31m";
|
|
16311
|
-
var ANSI_GREEN = "\x1B[32m";
|
|
16312
|
-
var ANSI_DIM = "\x1B[2m";
|
|
16313
|
-
var ANSI_RESET = "\x1B[0m";
|
|
16314
16310
|
function buildGbkLineDiffPreview(filePath, encoding, beforeText, afterText) {
|
|
16315
16311
|
const beforeLines = normalizeNewlines(beforeText).split("\n");
|
|
16316
16312
|
const afterLines = normalizeNewlines(afterText).split("\n");
|
|
16317
16313
|
const maxLines = Math.max(beforeLines.length, afterLines.length);
|
|
16318
16314
|
const lines = [
|
|
16319
|
-
|
|
16320
|
-
|
|
16315
|
+
`--- ${path2.basename(filePath)} (${encoding})`,
|
|
16316
|
+
`+++ ${path2.basename(filePath)} (${encoding})`
|
|
16321
16317
|
];
|
|
16322
16318
|
for (let index = 0; index < maxLines; index += 1) {
|
|
16323
16319
|
const before = beforeLines[index];
|
|
@@ -16327,10 +16323,10 @@ function buildGbkLineDiffPreview(filePath, encoding, beforeText, afterText) {
|
|
|
16327
16323
|
continue;
|
|
16328
16324
|
}
|
|
16329
16325
|
if (before !== void 0) {
|
|
16330
|
-
lines.push(
|
|
16326
|
+
lines.push(`-${before}`);
|
|
16331
16327
|
}
|
|
16332
16328
|
if (after !== void 0) {
|
|
16333
|
-
lines.push(
|
|
16329
|
+
lines.push(`+${after}`);
|
|
16334
16330
|
}
|
|
16335
16331
|
}
|
|
16336
16332
|
return lines.join("\n");
|
|
@@ -16357,10 +16353,10 @@ function assertInsertArguments(input) {
|
|
|
16357
16353
|
throw createGbkError("GBK_INVALID_ARGUMENT", "content \u4E0D\u80FD\u4E3A\u7A7A");
|
|
16358
16354
|
}
|
|
16359
16355
|
if (input.replaceAll !== void 0) {
|
|
16360
|
-
throw createGbkError("GBK_INVALID_ARGUMENT", "\u63D2\u5165\u6A21\u5F0F\u4E0D\u652F\
|
|
16356
|
+
throw createGbkError("GBK_INVALID_ARGUMENT", "\u63D2\u5165\u6A21\u5F0F\u4E0D\u652F\uFFFD\uFFFD? replaceAll");
|
|
16361
16357
|
}
|
|
16362
16358
|
if (input.startLine !== void 0 || input.endLine !== void 0 || input.startAnchor !== void 0 || input.endAnchor !== void 0) {
|
|
16363
|
-
throw createGbkError("GBK_INVALID_ARGUMENT", "\u63D2\u5165\u6A21\u5F0F\u4E0D\u652F\
|
|
16359
|
+
throw createGbkError("GBK_INVALID_ARGUMENT", "\u63D2\u5165\u6A21\u5F0F\u4E0D\u652F\uFFFD\uFFFD? startLine/endLine/startAnchor/endAnchor");
|
|
16364
16360
|
}
|
|
16365
16361
|
}
|
|
16366
16362
|
function findOccurrenceIndex(text, token, occurrence) {
|
|
@@ -16384,9 +16380,9 @@ function findOccurrenceIndex(text, token, occurrence) {
|
|
|
16384
16380
|
searchFrom = index + token.length;
|
|
16385
16381
|
}
|
|
16386
16382
|
if (count === 0) {
|
|
16387
|
-
throw createGbkError("GBK_NO_MATCH", `\u672A\u627E\u5230\u951A\
|
|
16383
|
+
throw createGbkError("GBK_NO_MATCH", `\u672A\u627E\u5230\u951A\uFFFD\uFFFD?: ${token}`);
|
|
16388
16384
|
}
|
|
16389
|
-
throw createGbkError("GBK_NO_MATCH", `\u951A\u70B9 ${token} \u53EA\u627E\
|
|
16385
|
+
throw createGbkError("GBK_NO_MATCH", `\u951A\u70B9 ${token} \u53EA\u627E\uFFFD\uFFFD? ${count} \u5904\uFF0C\u65E0\u6CD5\u4F7F\u7528\uFFFD\uFFFD? ${occurrence} \u5904`);
|
|
16390
16386
|
}
|
|
16391
16387
|
function insertByAnchor(text, mode, anchor, content, occurrence, ifExists, newlineStyle) {
|
|
16392
16388
|
const alignedContent = newlineStyle === "crlf" ? content.replace(/\r\n/g, "\n").replace(/\n/g, "\r\n") : newlineStyle === "lf" ? content.replace(/\r\n/g, "\n") : content;
|
|
@@ -16395,7 +16391,7 @@ function insertByAnchor(text, mode, anchor, content, occurrence, ifExists, newli
|
|
|
16395
16391
|
const alreadyExists = mode === "insertAfter" ? text.slice(insertionPoint, insertionPoint + alignedContent.length) === alignedContent : text.slice(Math.max(0, insertionPoint - alignedContent.length), insertionPoint) === alignedContent;
|
|
16396
16392
|
if (alreadyExists) {
|
|
16397
16393
|
if (ifExists === "error") {
|
|
16398
|
-
throw createGbkError("GBK_INVALID_ARGUMENT", "\u63D2\u5165\u4F4D\u7F6E\u5DF2\u5B58\u5728\u76F8\u540C\u5185\
|
|
16394
|
+
throw createGbkError("GBK_INVALID_ARGUMENT", "\u63D2\u5165\u4F4D\u7F6E\u5DF2\u5B58\u5728\u76F8\u540C\u5185\uFFFD\uFFFD?");
|
|
16399
16395
|
}
|
|
16400
16396
|
if (ifExists === "skip") {
|
|
16401
16397
|
return {
|
|
@@ -16436,7 +16432,7 @@ function normalizeOptionalPositiveInteger(value, name) {
|
|
|
16436
16432
|
}
|
|
16437
16433
|
function assertNotBinary(buffer) {
|
|
16438
16434
|
if (buffer.includes(0)) {
|
|
16439
|
-
throw createGbkError("GBK_BINARY_FILE", "\u7591\u4F3C\u4E8C\u8FDB\u5236\u6587\u4EF6\uFF0C\u65E0\u6CD5\
|
|
16435
|
+
throw createGbkError("GBK_BINARY_FILE", "\u7591\u4F3C\u4E8C\u8FDB\u5236\u6587\u4EF6\uFF0C\u65E0\u6CD5\uFFFD\uFFFD? GBK \u6587\u672C\u5904\u7406");
|
|
16440
16436
|
}
|
|
16441
16437
|
}
|
|
16442
16438
|
function detectNewlineStyle(text) {
|
|
@@ -16517,14 +16513,14 @@ function applyAnchors(text, startAnchor, endAnchor) {
|
|
|
16517
16513
|
if (startAnchor) {
|
|
16518
16514
|
const found = text.indexOf(startAnchor);
|
|
16519
16515
|
if (found === -1) {
|
|
16520
|
-
throw createGbkError("GBK_NO_MATCH", `\u672A\u627E\u5230\u8D77\u59CB\u951A\
|
|
16516
|
+
throw createGbkError("GBK_NO_MATCH", `\u672A\u627E\u5230\u8D77\u59CB\u951A\uFFFD\uFFFD?: ${startAnchor}`);
|
|
16521
16517
|
}
|
|
16522
16518
|
rangeStart = found + startAnchor.length;
|
|
16523
16519
|
}
|
|
16524
16520
|
if (endAnchor) {
|
|
16525
16521
|
const found = text.indexOf(endAnchor, rangeStart);
|
|
16526
16522
|
if (found === -1) {
|
|
16527
|
-
throw createGbkError("GBK_NO_MATCH", `\u672A\u627E\u5230\u7ED3\u675F\u951A\
|
|
16523
|
+
throw createGbkError("GBK_NO_MATCH", `\u672A\u627E\u5230\u7ED3\u675F\u951A\uFFFD\uFFFD?: ${endAnchor}`);
|
|
16528
16524
|
}
|
|
16529
16525
|
rangeEnd = found;
|
|
16530
16526
|
}
|
|
@@ -16577,9 +16573,9 @@ function getNearestContext(content, oldString) {
|
|
|
16577
16573
|
}
|
|
16578
16574
|
function buildNoMatchMessage(content, oldString) {
|
|
16579
16575
|
return [
|
|
16580
|
-
"\u672A\u627E\u5230\u9700\u8981\u66FF\u6362\u7684\u6587\u672C\
|
|
16581
|
-
"oldString \u5FC5\u987B\u4E0E\u6587\u4EF6\u5B9E\u9645\u5185\u5BB9\u5B8C\u5168\u5BF9\u5E94\uFF0C\u6216\u4EC5\u5728\u6362\
|
|
16582
|
-
"\u6700\u63A5\u8FD1\u7684\u4E0A\u4E0B\u6587\
|
|
16576
|
+
"\u672A\u627E\u5230\u9700\u8981\u66FF\u6362\u7684\u6587\u672C\uFFFD\uFFFD?",
|
|
16577
|
+
"oldString \u5FC5\u987B\u4E0E\u6587\u4EF6\u5B9E\u9645\u5185\u5BB9\u5B8C\u5168\u5BF9\u5E94\uFF0C\u6216\u4EC5\u5728\u6362\uFFFD\uFFFD?/\u5C3E\u968F\u7A7A\u884C\u4E0A\u5B58\u5728\u8F7B\u5FAE\u5DEE\u5F02\uFFFD\uFFFD?",
|
|
16578
|
+
"\u6700\u63A5\u8FD1\u7684\u4E0A\u4E0B\u6587\uFFFD\uFFFD?",
|
|
16583
16579
|
getNearestContext(content, oldString)
|
|
16584
16580
|
].join("\n");
|
|
16585
16581
|
}
|
|
@@ -16636,6 +16632,8 @@ function matchLooseBlock(contentLines, oldLines, newLines, newlineStyle, content
|
|
|
16636
16632
|
break;
|
|
16637
16633
|
}
|
|
16638
16634
|
if (oldIndex === oldLines.length) {
|
|
16635
|
+
const matchedLines = contentLines.slice(start, contentIndex);
|
|
16636
|
+
const matchedOriginal = matchedLines.join("\n");
|
|
16639
16637
|
const replacedNormalized = [
|
|
16640
16638
|
...contentLines.slice(0, start),
|
|
16641
16639
|
...newLines,
|
|
@@ -16643,6 +16641,7 @@ function matchLooseBlock(contentLines, oldLines, newLines, newlineStyle, content
|
|
|
16643
16641
|
].join("\n");
|
|
16644
16642
|
return {
|
|
16645
16643
|
occurrencesBefore: 1,
|
|
16644
|
+
matchedOriginal,
|
|
16646
16645
|
content: newlineStyle === "crlf" ? replacedNormalized.replace(/\n/g, "\r\n") : replacedNormalized
|
|
16647
16646
|
};
|
|
16648
16647
|
}
|
|
@@ -16699,10 +16698,10 @@ async function resolveReadableGbkFile(input) {
|
|
|
16699
16698
|
try {
|
|
16700
16699
|
stat = await fs2.stat(candidatePath);
|
|
16701
16700
|
} catch (error45) {
|
|
16702
|
-
throw createGbkError("GBK_FILE_NOT_FOUND", `\u6587\u4EF6\u4E0D\u5B58\
|
|
16701
|
+
throw createGbkError("GBK_FILE_NOT_FOUND", `\u6587\u4EF6\u4E0D\u5B58\uFFFD\uFFFD?: ${candidatePath}`, error45);
|
|
16703
16702
|
}
|
|
16704
16703
|
if (stat.isDirectory()) {
|
|
16705
|
-
throw createGbkError("GBK_IS_DIRECTORY", `\u76EE\u6807\u8DEF\u5F84\u662F\u76EE\
|
|
16704
|
+
throw createGbkError("GBK_IS_DIRECTORY", `\u76EE\u6807\u8DEF\u5F84\u662F\u76EE\uFFFD\uFFFD?: ${candidatePath}`);
|
|
16706
16705
|
}
|
|
16707
16706
|
return {
|
|
16708
16707
|
filePath: candidatePath,
|
|
@@ -16899,7 +16898,7 @@ function replaceScopedTextContent(scopeText, oldString, newString, replaceAll, n
|
|
|
16899
16898
|
} else if (occurrencesBefore === 0) {
|
|
16900
16899
|
throw createGbkError("GBK_NO_MATCH", buildNoMatchMessage(scopeText, oldString));
|
|
16901
16900
|
} else if (occurrencesBefore > 1) {
|
|
16902
|
-
throw createGbkError("GBK_MULTIPLE_MATCHES", `\u627E\u5230\u591A\u4E2A\u5339\u914D\
|
|
16901
|
+
throw createGbkError("GBK_MULTIPLE_MATCHES", `\u627E\u5230\u591A\u4E2A\u5339\u914D\uFFFD\uFFFD?: ${oldString}`);
|
|
16903
16902
|
}
|
|
16904
16903
|
const alignedNewString = alignTextToNewlineStyle(newString, newlineStyle);
|
|
16905
16904
|
return {
|
|
@@ -17004,7 +17003,7 @@ async function replaceLargeGbkFileByAnchor(input) {
|
|
|
17004
17003
|
const alreadyExists = input.mode === "insertAfter" ? after.startsWith(alignedContent) : before.endsWith(alignedContent);
|
|
17005
17004
|
if (alreadyExists) {
|
|
17006
17005
|
if (input.ifExists === "error") {
|
|
17007
|
-
throw createGbkError("GBK_INVALID_ARGUMENT", "\u63D2\u5165\u4F4D\u7F6E\u5DF2\u5B58\u5728\u76F8\u540C\u5185\
|
|
17006
|
+
throw createGbkError("GBK_INVALID_ARGUMENT", "\u63D2\u5165\u4F4D\u7F6E\u5DF2\u5B58\u5728\u76F8\u540C\u5185\uFFFD\uFFFD?");
|
|
17008
17007
|
}
|
|
17009
17008
|
if (input.ifExists === "skip") {
|
|
17010
17009
|
skipped = true;
|
|
@@ -17051,7 +17050,7 @@ async function replaceLargeGbkFileByAnchor(input) {
|
|
|
17051
17050
|
const alreadyExists = input.mode === "insertAfter" ? after.startsWith(alignedContent) : before.endsWith(alignedContent);
|
|
17052
17051
|
if (alreadyExists) {
|
|
17053
17052
|
if (input.ifExists === "error") {
|
|
17054
|
-
throw createGbkError("GBK_INVALID_ARGUMENT", "\u63D2\u5165\u4F4D\u7F6E\u5DF2\u5B58\u5728\u76F8\u540C\u5185\
|
|
17053
|
+
throw createGbkError("GBK_INVALID_ARGUMENT", "\u63D2\u5165\u4F4D\u7F6E\u5DF2\u5B58\u5728\u76F8\u540C\u5185\uFFFD\uFFFD?");
|
|
17055
17054
|
}
|
|
17056
17055
|
if (input.ifExists === "skip") {
|
|
17057
17056
|
skipped = true;
|
|
@@ -17065,10 +17064,10 @@ async function replaceLargeGbkFileByAnchor(input) {
|
|
|
17065
17064
|
}
|
|
17066
17065
|
}
|
|
17067
17066
|
if (!inserted && totalMatches === 0) {
|
|
17068
|
-
throw createGbkError("GBK_NO_MATCH", `\u672A\u627E\u5230\u951A\
|
|
17067
|
+
throw createGbkError("GBK_NO_MATCH", `\u672A\u627E\u5230\u951A\uFFFD\uFFFD?: ${input.anchor}`);
|
|
17069
17068
|
}
|
|
17070
17069
|
if (!inserted && totalMatches > 0) {
|
|
17071
|
-
throw createGbkError("GBK_NO_MATCH", `\u951A\u70B9 ${input.anchor} \u53EA\u627E\
|
|
17070
|
+
throw createGbkError("GBK_NO_MATCH", `\u951A\u70B9 ${input.anchor} \u53EA\u627E\uFFFD\uFFFD? ${totalMatches} \u5904\uFF0C\u65E0\u6CD5\u4F7F\u7528\uFFFD\uFFFD? ${input.occurrence} \u5904`);
|
|
17072
17071
|
}
|
|
17073
17072
|
await finalizeInserted();
|
|
17074
17073
|
await handle.close();
|
|
@@ -17131,10 +17130,10 @@ async function replaceLargeGbkFileText(input) {
|
|
|
17131
17130
|
});
|
|
17132
17131
|
await flushText("", true);
|
|
17133
17132
|
if (occurrencesBefore === 0) {
|
|
17134
|
-
throw createGbkError("GBK_NO_MATCH", `\u672A\u627E\u5230\u8981\u66FF\u6362\u7684\u5185\
|
|
17133
|
+
throw createGbkError("GBK_NO_MATCH", `\u672A\u627E\u5230\u8981\u66FF\u6362\u7684\u5185\uFFFD\uFFFD?: ${input.oldString}`);
|
|
17135
17134
|
}
|
|
17136
17135
|
if (!input.replaceAll && occurrencesBefore > 1) {
|
|
17137
|
-
throw createGbkError("GBK_MULTIPLE_MATCHES", `\u627E\u5230\u591A\u4E2A\u5339\u914D\
|
|
17136
|
+
throw createGbkError("GBK_MULTIPLE_MATCHES", `\u627E\u5230\u591A\u4E2A\u5339\u914D\uFFFD\uFFFD?: ${input.oldString}`);
|
|
17138
17137
|
}
|
|
17139
17138
|
await handle.close();
|
|
17140
17139
|
const mode = typeof input.stat.mode === "bigint" ? Number(input.stat.mode) : input.stat.mode;
|
|
@@ -17272,7 +17271,7 @@ async function replaceGbkFileText(input) {
|
|
|
17272
17271
|
occurrencesBefore: loose.occurrencesBefore,
|
|
17273
17272
|
bytesRead: current.bytesRead,
|
|
17274
17273
|
bytesWritten: buffer2.byteLength,
|
|
17275
|
-
diffPreview: buildGbkLineDiffPreview(current.filePath, current.encoding,
|
|
17274
|
+
diffPreview: buildGbkLineDiffPreview(current.filePath, current.encoding, loose.matchedOriginal, input.newString ?? "")
|
|
17276
17275
|
};
|
|
17277
17276
|
}
|
|
17278
17277
|
}
|
|
@@ -17283,7 +17282,7 @@ async function replaceGbkFileText(input) {
|
|
|
17283
17282
|
} else if (occurrencesBefore === 0) {
|
|
17284
17283
|
throw createGbkError("GBK_NO_MATCH", buildNoMatchMessage(scope.selectedText, effectiveOldString));
|
|
17285
17284
|
} else if (occurrencesBefore > 1) {
|
|
17286
|
-
throw createGbkError("GBK_MULTIPLE_MATCHES", `\u627E\u5230\u591A\u4E2A\u5339\u914D\
|
|
17285
|
+
throw createGbkError("GBK_MULTIPLE_MATCHES", `\u627E\u5230\u591A\u4E2A\u5339\u914D\uFFFD\uFFFD?: ${effectiveOldString}`);
|
|
17287
17286
|
}
|
|
17288
17287
|
const fileNewlineStyle = detectNewlineStyle(current.content);
|
|
17289
17288
|
const alignedNewString = fileNewlineStyle === "crlf" ? input.newString.replace(/\r\n/g, "\n").replace(/\n/g, "\r\n") : fileNewlineStyle === "lf" ? input.newString.replace(/\r\n/g, "\n") : input.newString;
|
|
@@ -16329,7 +16329,7 @@ function normalizeOptionalPositiveInteger(value, name) {
|
|
|
16329
16329
|
}
|
|
16330
16330
|
function assertNotBinary(buffer) {
|
|
16331
16331
|
if (buffer.includes(0)) {
|
|
16332
|
-
throw createGbkError("GBK_BINARY_FILE", "\u7591\u4F3C\u4E8C\u8FDB\u5236\u6587\u4EF6\uFF0C\u65E0\u6CD5\
|
|
16332
|
+
throw createGbkError("GBK_BINARY_FILE", "\u7591\u4F3C\u4E8C\u8FDB\u5236\u6587\u4EF6\uFF0C\u65E0\u6CD5\uFFFD\uFFFD? GBK \u6587\u672C\u5904\u7406");
|
|
16333
16333
|
}
|
|
16334
16334
|
}
|
|
16335
16335
|
function splitLinesWithNumbers(text, offset = 1, limit = 2e3) {
|
|
@@ -16420,10 +16420,10 @@ async function resolveReadableGbkFile(input) {
|
|
|
16420
16420
|
try {
|
|
16421
16421
|
stat = await fs2.stat(candidatePath);
|
|
16422
16422
|
} catch (error45) {
|
|
16423
|
-
throw createGbkError("GBK_FILE_NOT_FOUND", `\u6587\u4EF6\u4E0D\u5B58\
|
|
16423
|
+
throw createGbkError("GBK_FILE_NOT_FOUND", `\u6587\u4EF6\u4E0D\u5B58\uFFFD\uFFFD?: ${candidatePath}`, error45);
|
|
16424
16424
|
}
|
|
16425
16425
|
if (stat.isDirectory()) {
|
|
16426
|
-
throw createGbkError("GBK_IS_DIRECTORY", `\u76EE\u6807\u8DEF\u5F84\u662F\u76EE\
|
|
16426
|
+
throw createGbkError("GBK_IS_DIRECTORY", `\u76EE\u6807\u8DEF\u5F84\u662F\u76EE\uFFFD\uFFFD?: ${candidatePath}`);
|
|
16427
16427
|
}
|
|
16428
16428
|
return {
|
|
16429
16429
|
filePath: candidatePath,
|
|
@@ -16313,7 +16313,7 @@ function assertEncodingSupported(encoding) {
|
|
|
16313
16313
|
}
|
|
16314
16314
|
function assertNotBinary(buffer) {
|
|
16315
16315
|
if (buffer.includes(0)) {
|
|
16316
|
-
throw createGbkError("GBK_BINARY_FILE", "\u7591\u4F3C\u4E8C\u8FDB\u5236\u6587\u4EF6\uFF0C\u65E0\u6CD5\
|
|
16316
|
+
throw createGbkError("GBK_BINARY_FILE", "\u7591\u4F3C\u4E8C\u8FDB\u5236\u6587\u4EF6\uFF0C\u65E0\u6CD5\uFFFD\uFFFD? GBK \u6587\u672C\u5904\u7406");
|
|
16317
16317
|
}
|
|
16318
16318
|
}
|
|
16319
16319
|
async function resolveReadableGbkFile(input) {
|
|
@@ -16324,10 +16324,10 @@ async function resolveReadableGbkFile(input) {
|
|
|
16324
16324
|
try {
|
|
16325
16325
|
stat = await fs2.stat(candidatePath);
|
|
16326
16326
|
} catch (error45) {
|
|
16327
|
-
throw createGbkError("GBK_FILE_NOT_FOUND", `\u6587\u4EF6\u4E0D\u5B58\
|
|
16327
|
+
throw createGbkError("GBK_FILE_NOT_FOUND", `\u6587\u4EF6\u4E0D\u5B58\uFFFD\uFFFD?: ${candidatePath}`, error45);
|
|
16328
16328
|
}
|
|
16329
16329
|
if (stat.isDirectory()) {
|
|
16330
|
-
throw createGbkError("GBK_IS_DIRECTORY", `\u76EE\u6807\u8DEF\u5F84\u662F\u76EE\
|
|
16330
|
+
throw createGbkError("GBK_IS_DIRECTORY", `\u76EE\u6807\u8DEF\u5F84\u662F\u76EE\uFFFD\uFFFD?: ${candidatePath}`);
|
|
16331
16331
|
}
|
|
16332
16332
|
return {
|
|
16333
16333
|
filePath: candidatePath,
|
|
@@ -16370,10 +16370,10 @@ async function writeGbkFile(input) {
|
|
|
16370
16370
|
try {
|
|
16371
16371
|
const stat = await fs2.stat(candidatePath);
|
|
16372
16372
|
if (stat.isDirectory()) {
|
|
16373
|
-
throw createGbkError("GBK_IS_DIRECTORY", `\u76EE\u6807\u8DEF\u5F84\u662F\u76EE\
|
|
16373
|
+
throw createGbkError("GBK_IS_DIRECTORY", `\u76EE\u6807\u8DEF\u5F84\u662F\u76EE\uFFFD\uFFFD?: ${candidatePath}`);
|
|
16374
16374
|
}
|
|
16375
16375
|
if (!overwrite) {
|
|
16376
|
-
throw createGbkError("GBK_FILE_EXISTS", `\u76EE\u6807\u6587\u4EF6\u5DF2\u5B58\
|
|
16376
|
+
throw createGbkError("GBK_FILE_EXISTS", `\u76EE\u6807\u6587\u4EF6\u5DF2\u5B58\uFFFD\uFFFD?: ${candidatePath}`);
|
|
16377
16377
|
}
|
|
16378
16378
|
} catch (error45) {
|
|
16379
16379
|
if (error45 instanceof Error && "code" in error45) {
|
|
@@ -16577,17 +16577,13 @@ function assertInsertArguments(input) {
|
|
|
16577
16577
|
throw createTextError("GBK_INVALID_ARGUMENT", "\u63D2\u5165\u6A21\u5F0F\u4E0D\u652F\u6301 startLine/endLine/startAnchor/endAnchor");
|
|
16578
16578
|
}
|
|
16579
16579
|
}
|
|
16580
|
-
var ANSI_RED = "\x1B[31m";
|
|
16581
|
-
var ANSI_GREEN = "\x1B[32m";
|
|
16582
|
-
var ANSI_DIM = "\x1B[2m";
|
|
16583
|
-
var ANSI_RESET = "\x1B[0m";
|
|
16584
16580
|
function buildLineDiffPreview(filePath, encoding, beforeText, afterText) {
|
|
16585
16581
|
const beforeLines = normalizeNewlines(beforeText).split("\n");
|
|
16586
16582
|
const afterLines = normalizeNewlines(afterText).split("\n");
|
|
16587
16583
|
const maxLines = Math.max(beforeLines.length, afterLines.length);
|
|
16588
16584
|
const lines = [
|
|
16589
|
-
|
|
16590
|
-
|
|
16585
|
+
`--- ${path3.basename(filePath)} (${encoding})`,
|
|
16586
|
+
`+++ ${path3.basename(filePath)} (${encoding})`
|
|
16591
16587
|
];
|
|
16592
16588
|
for (let index = 0; index < maxLines; index += 1) {
|
|
16593
16589
|
const before = beforeLines[index];
|
|
@@ -16597,10 +16593,10 @@ function buildLineDiffPreview(filePath, encoding, beforeText, afterText) {
|
|
|
16597
16593
|
continue;
|
|
16598
16594
|
}
|
|
16599
16595
|
if (before !== void 0) {
|
|
16600
|
-
lines.push(
|
|
16596
|
+
lines.push(`-${before}`);
|
|
16601
16597
|
}
|
|
16602
16598
|
if (after !== void 0) {
|
|
16603
|
-
lines.push(
|
|
16599
|
+
lines.push(`+${after}`);
|
|
16604
16600
|
}
|
|
16605
16601
|
}
|
|
16606
16602
|
return lines.join("\n");
|
package/dist/plugin/index.js
CHANGED
|
@@ -16308,17 +16308,13 @@ async function assertPathAllowed(filePath, context, allowExternal = false) {
|
|
|
16308
16308
|
var STREAMING_FILE_SIZE_THRESHOLD_BYTES = 1024 * 1024;
|
|
16309
16309
|
var STREAM_READ_CHUNK_SIZE_BYTES = 1024 * 1024;
|
|
16310
16310
|
var gbkLineIndexCache = /* @__PURE__ */ new Map();
|
|
16311
|
-
var ANSI_RED = "\x1B[31m";
|
|
16312
|
-
var ANSI_GREEN = "\x1B[32m";
|
|
16313
|
-
var ANSI_DIM = "\x1B[2m";
|
|
16314
|
-
var ANSI_RESET = "\x1B[0m";
|
|
16315
16311
|
function buildGbkLineDiffPreview(filePath, encoding, beforeText, afterText) {
|
|
16316
16312
|
const beforeLines = normalizeNewlines(beforeText).split("\n");
|
|
16317
16313
|
const afterLines = normalizeNewlines(afterText).split("\n");
|
|
16318
16314
|
const maxLines = Math.max(beforeLines.length, afterLines.length);
|
|
16319
16315
|
const lines = [
|
|
16320
|
-
|
|
16321
|
-
|
|
16316
|
+
`--- ${path2.basename(filePath)} (${encoding})`,
|
|
16317
|
+
`+++ ${path2.basename(filePath)} (${encoding})`
|
|
16322
16318
|
];
|
|
16323
16319
|
for (let index = 0; index < maxLines; index += 1) {
|
|
16324
16320
|
const before = beforeLines[index];
|
|
@@ -16328,10 +16324,10 @@ function buildGbkLineDiffPreview(filePath, encoding, beforeText, afterText) {
|
|
|
16328
16324
|
continue;
|
|
16329
16325
|
}
|
|
16330
16326
|
if (before !== void 0) {
|
|
16331
|
-
lines.push(
|
|
16327
|
+
lines.push(`-${before}`);
|
|
16332
16328
|
}
|
|
16333
16329
|
if (after !== void 0) {
|
|
16334
|
-
lines.push(
|
|
16330
|
+
lines.push(`+${after}`);
|
|
16335
16331
|
}
|
|
16336
16332
|
}
|
|
16337
16333
|
return lines.join("\n");
|
|
@@ -16358,10 +16354,10 @@ function assertInsertArguments(input) {
|
|
|
16358
16354
|
throw createGbkError("GBK_INVALID_ARGUMENT", "content \u4E0D\u80FD\u4E3A\u7A7A");
|
|
16359
16355
|
}
|
|
16360
16356
|
if (input.replaceAll !== void 0) {
|
|
16361
|
-
throw createGbkError("GBK_INVALID_ARGUMENT", "\u63D2\u5165\u6A21\u5F0F\u4E0D\u652F\
|
|
16357
|
+
throw createGbkError("GBK_INVALID_ARGUMENT", "\u63D2\u5165\u6A21\u5F0F\u4E0D\u652F\uFFFD\uFFFD? replaceAll");
|
|
16362
16358
|
}
|
|
16363
16359
|
if (input.startLine !== void 0 || input.endLine !== void 0 || input.startAnchor !== void 0 || input.endAnchor !== void 0) {
|
|
16364
|
-
throw createGbkError("GBK_INVALID_ARGUMENT", "\u63D2\u5165\u6A21\u5F0F\u4E0D\u652F\
|
|
16360
|
+
throw createGbkError("GBK_INVALID_ARGUMENT", "\u63D2\u5165\u6A21\u5F0F\u4E0D\u652F\uFFFD\uFFFD? startLine/endLine/startAnchor/endAnchor");
|
|
16365
16361
|
}
|
|
16366
16362
|
}
|
|
16367
16363
|
function findOccurrenceIndex(text, token, occurrence) {
|
|
@@ -16385,9 +16381,9 @@ function findOccurrenceIndex(text, token, occurrence) {
|
|
|
16385
16381
|
searchFrom = index + token.length;
|
|
16386
16382
|
}
|
|
16387
16383
|
if (count === 0) {
|
|
16388
|
-
throw createGbkError("GBK_NO_MATCH", `\u672A\u627E\u5230\u951A\
|
|
16384
|
+
throw createGbkError("GBK_NO_MATCH", `\u672A\u627E\u5230\u951A\uFFFD\uFFFD?: ${token}`);
|
|
16389
16385
|
}
|
|
16390
|
-
throw createGbkError("GBK_NO_MATCH", `\u951A\u70B9 ${token} \u53EA\u627E\
|
|
16386
|
+
throw createGbkError("GBK_NO_MATCH", `\u951A\u70B9 ${token} \u53EA\u627E\uFFFD\uFFFD? ${count} \u5904\uFF0C\u65E0\u6CD5\u4F7F\u7528\uFFFD\uFFFD? ${occurrence} \u5904`);
|
|
16391
16387
|
}
|
|
16392
16388
|
function insertByAnchor(text, mode, anchor, content, occurrence, ifExists, newlineStyle) {
|
|
16393
16389
|
const alignedContent = newlineStyle === "crlf" ? content.replace(/\r\n/g, "\n").replace(/\n/g, "\r\n") : newlineStyle === "lf" ? content.replace(/\r\n/g, "\n") : content;
|
|
@@ -16396,7 +16392,7 @@ function insertByAnchor(text, mode, anchor, content, occurrence, ifExists, newli
|
|
|
16396
16392
|
const alreadyExists = mode === "insertAfter" ? text.slice(insertionPoint, insertionPoint + alignedContent.length) === alignedContent : text.slice(Math.max(0, insertionPoint - alignedContent.length), insertionPoint) === alignedContent;
|
|
16397
16393
|
if (alreadyExists) {
|
|
16398
16394
|
if (ifExists === "error") {
|
|
16399
|
-
throw createGbkError("GBK_INVALID_ARGUMENT", "\u63D2\u5165\u4F4D\u7F6E\u5DF2\u5B58\u5728\u76F8\u540C\u5185\
|
|
16395
|
+
throw createGbkError("GBK_INVALID_ARGUMENT", "\u63D2\u5165\u4F4D\u7F6E\u5DF2\u5B58\u5728\u76F8\u540C\u5185\uFFFD\uFFFD?");
|
|
16400
16396
|
}
|
|
16401
16397
|
if (ifExists === "skip") {
|
|
16402
16398
|
return {
|
|
@@ -16437,7 +16433,7 @@ function normalizeOptionalPositiveInteger(value, name) {
|
|
|
16437
16433
|
}
|
|
16438
16434
|
function assertNotBinary(buffer) {
|
|
16439
16435
|
if (buffer.includes(0)) {
|
|
16440
|
-
throw createGbkError("GBK_BINARY_FILE", "\u7591\u4F3C\u4E8C\u8FDB\u5236\u6587\u4EF6\uFF0C\u65E0\u6CD5\
|
|
16436
|
+
throw createGbkError("GBK_BINARY_FILE", "\u7591\u4F3C\u4E8C\u8FDB\u5236\u6587\u4EF6\uFF0C\u65E0\u6CD5\uFFFD\uFFFD? GBK \u6587\u672C\u5904\u7406");
|
|
16441
16437
|
}
|
|
16442
16438
|
}
|
|
16443
16439
|
function splitLinesWithNumbers(text, offset = 1, limit = 2e3) {
|
|
@@ -16567,14 +16563,14 @@ function applyAnchors(text, startAnchor, endAnchor) {
|
|
|
16567
16563
|
if (startAnchor) {
|
|
16568
16564
|
const found = text.indexOf(startAnchor);
|
|
16569
16565
|
if (found === -1) {
|
|
16570
|
-
throw createGbkError("GBK_NO_MATCH", `\u672A\u627E\u5230\u8D77\u59CB\u951A\
|
|
16566
|
+
throw createGbkError("GBK_NO_MATCH", `\u672A\u627E\u5230\u8D77\u59CB\u951A\uFFFD\uFFFD?: ${startAnchor}`);
|
|
16571
16567
|
}
|
|
16572
16568
|
rangeStart = found + startAnchor.length;
|
|
16573
16569
|
}
|
|
16574
16570
|
if (endAnchor) {
|
|
16575
16571
|
const found = text.indexOf(endAnchor, rangeStart);
|
|
16576
16572
|
if (found === -1) {
|
|
16577
|
-
throw createGbkError("GBK_NO_MATCH", `\u672A\u627E\u5230\u7ED3\u675F\u951A\
|
|
16573
|
+
throw createGbkError("GBK_NO_MATCH", `\u672A\u627E\u5230\u7ED3\u675F\u951A\uFFFD\uFFFD?: ${endAnchor}`);
|
|
16578
16574
|
}
|
|
16579
16575
|
rangeEnd = found;
|
|
16580
16576
|
}
|
|
@@ -16627,9 +16623,9 @@ function getNearestContext(content, oldString) {
|
|
|
16627
16623
|
}
|
|
16628
16624
|
function buildNoMatchMessage(content, oldString) {
|
|
16629
16625
|
return [
|
|
16630
|
-
"\u672A\u627E\u5230\u9700\u8981\u66FF\u6362\u7684\u6587\u672C\
|
|
16631
|
-
"oldString \u5FC5\u987B\u4E0E\u6587\u4EF6\u5B9E\u9645\u5185\u5BB9\u5B8C\u5168\u5BF9\u5E94\uFF0C\u6216\u4EC5\u5728\u6362\
|
|
16632
|
-
"\u6700\u63A5\u8FD1\u7684\u4E0A\u4E0B\u6587\
|
|
16626
|
+
"\u672A\u627E\u5230\u9700\u8981\u66FF\u6362\u7684\u6587\u672C\uFFFD\uFFFD?",
|
|
16627
|
+
"oldString \u5FC5\u987B\u4E0E\u6587\u4EF6\u5B9E\u9645\u5185\u5BB9\u5B8C\u5168\u5BF9\u5E94\uFF0C\u6216\u4EC5\u5728\u6362\uFFFD\uFFFD?/\u5C3E\u968F\u7A7A\u884C\u4E0A\u5B58\u5728\u8F7B\u5FAE\u5DEE\u5F02\uFFFD\uFFFD?",
|
|
16628
|
+
"\u6700\u63A5\u8FD1\u7684\u4E0A\u4E0B\u6587\uFFFD\uFFFD?",
|
|
16633
16629
|
getNearestContext(content, oldString)
|
|
16634
16630
|
].join("\n");
|
|
16635
16631
|
}
|
|
@@ -16686,6 +16682,8 @@ function matchLooseBlock(contentLines, oldLines, newLines, newlineStyle, content
|
|
|
16686
16682
|
break;
|
|
16687
16683
|
}
|
|
16688
16684
|
if (oldIndex === oldLines.length) {
|
|
16685
|
+
const matchedLines = contentLines.slice(start, contentIndex);
|
|
16686
|
+
const matchedOriginal = matchedLines.join("\n");
|
|
16689
16687
|
const replacedNormalized = [
|
|
16690
16688
|
...contentLines.slice(0, start),
|
|
16691
16689
|
...newLines,
|
|
@@ -16693,6 +16691,7 @@ function matchLooseBlock(contentLines, oldLines, newLines, newlineStyle, content
|
|
|
16693
16691
|
].join("\n");
|
|
16694
16692
|
return {
|
|
16695
16693
|
occurrencesBefore: 1,
|
|
16694
|
+
matchedOriginal,
|
|
16696
16695
|
content: newlineStyle === "crlf" ? replacedNormalized.replace(/\n/g, "\r\n") : replacedNormalized
|
|
16697
16696
|
};
|
|
16698
16697
|
}
|
|
@@ -16749,10 +16748,10 @@ async function resolveReadableGbkFile(input) {
|
|
|
16749
16748
|
try {
|
|
16750
16749
|
stat = await fs2.stat(candidatePath);
|
|
16751
16750
|
} catch (error45) {
|
|
16752
|
-
throw createGbkError("GBK_FILE_NOT_FOUND", `\u6587\u4EF6\u4E0D\u5B58\
|
|
16751
|
+
throw createGbkError("GBK_FILE_NOT_FOUND", `\u6587\u4EF6\u4E0D\u5B58\uFFFD\uFFFD?: ${candidatePath}`, error45);
|
|
16753
16752
|
}
|
|
16754
16753
|
if (stat.isDirectory()) {
|
|
16755
|
-
throw createGbkError("GBK_IS_DIRECTORY", `\u76EE\u6807\u8DEF\u5F84\u662F\u76EE\
|
|
16754
|
+
throw createGbkError("GBK_IS_DIRECTORY", `\u76EE\u6807\u8DEF\u5F84\u662F\u76EE\uFFFD\uFFFD?: ${candidatePath}`);
|
|
16756
16755
|
}
|
|
16757
16756
|
return {
|
|
16758
16757
|
filePath: candidatePath,
|
|
@@ -16957,7 +16956,7 @@ function replaceScopedTextContent(scopeText, oldString, newString, replaceAll, n
|
|
|
16957
16956
|
} else if (occurrencesBefore === 0) {
|
|
16958
16957
|
throw createGbkError("GBK_NO_MATCH", buildNoMatchMessage(scopeText, oldString));
|
|
16959
16958
|
} else if (occurrencesBefore > 1) {
|
|
16960
|
-
throw createGbkError("GBK_MULTIPLE_MATCHES", `\u627E\u5230\u591A\u4E2A\u5339\u914D\
|
|
16959
|
+
throw createGbkError("GBK_MULTIPLE_MATCHES", `\u627E\u5230\u591A\u4E2A\u5339\u914D\uFFFD\uFFFD?: ${oldString}`);
|
|
16961
16960
|
}
|
|
16962
16961
|
const alignedNewString = alignTextToNewlineStyle(newString, newlineStyle);
|
|
16963
16962
|
return {
|
|
@@ -17062,7 +17061,7 @@ async function replaceLargeGbkFileByAnchor(input) {
|
|
|
17062
17061
|
const alreadyExists = input.mode === "insertAfter" ? after.startsWith(alignedContent) : before.endsWith(alignedContent);
|
|
17063
17062
|
if (alreadyExists) {
|
|
17064
17063
|
if (input.ifExists === "error") {
|
|
17065
|
-
throw createGbkError("GBK_INVALID_ARGUMENT", "\u63D2\u5165\u4F4D\u7F6E\u5DF2\u5B58\u5728\u76F8\u540C\u5185\
|
|
17064
|
+
throw createGbkError("GBK_INVALID_ARGUMENT", "\u63D2\u5165\u4F4D\u7F6E\u5DF2\u5B58\u5728\u76F8\u540C\u5185\uFFFD\uFFFD?");
|
|
17066
17065
|
}
|
|
17067
17066
|
if (input.ifExists === "skip") {
|
|
17068
17067
|
skipped = true;
|
|
@@ -17109,7 +17108,7 @@ async function replaceLargeGbkFileByAnchor(input) {
|
|
|
17109
17108
|
const alreadyExists = input.mode === "insertAfter" ? after.startsWith(alignedContent) : before.endsWith(alignedContent);
|
|
17110
17109
|
if (alreadyExists) {
|
|
17111
17110
|
if (input.ifExists === "error") {
|
|
17112
|
-
throw createGbkError("GBK_INVALID_ARGUMENT", "\u63D2\u5165\u4F4D\u7F6E\u5DF2\u5B58\u5728\u76F8\u540C\u5185\
|
|
17111
|
+
throw createGbkError("GBK_INVALID_ARGUMENT", "\u63D2\u5165\u4F4D\u7F6E\u5DF2\u5B58\u5728\u76F8\u540C\u5185\uFFFD\uFFFD?");
|
|
17113
17112
|
}
|
|
17114
17113
|
if (input.ifExists === "skip") {
|
|
17115
17114
|
skipped = true;
|
|
@@ -17123,10 +17122,10 @@ async function replaceLargeGbkFileByAnchor(input) {
|
|
|
17123
17122
|
}
|
|
17124
17123
|
}
|
|
17125
17124
|
if (!inserted && totalMatches === 0) {
|
|
17126
|
-
throw createGbkError("GBK_NO_MATCH", `\u672A\u627E\u5230\u951A\
|
|
17125
|
+
throw createGbkError("GBK_NO_MATCH", `\u672A\u627E\u5230\u951A\uFFFD\uFFFD?: ${input.anchor}`);
|
|
17127
17126
|
}
|
|
17128
17127
|
if (!inserted && totalMatches > 0) {
|
|
17129
|
-
throw createGbkError("GBK_NO_MATCH", `\u951A\u70B9 ${input.anchor} \u53EA\u627E\
|
|
17128
|
+
throw createGbkError("GBK_NO_MATCH", `\u951A\u70B9 ${input.anchor} \u53EA\u627E\uFFFD\uFFFD? ${totalMatches} \u5904\uFF0C\u65E0\u6CD5\u4F7F\u7528\uFFFD\uFFFD? ${input.occurrence} \u5904`);
|
|
17130
17129
|
}
|
|
17131
17130
|
await finalizeInserted();
|
|
17132
17131
|
await handle.close();
|
|
@@ -17189,10 +17188,10 @@ async function replaceLargeGbkFileText(input) {
|
|
|
17189
17188
|
});
|
|
17190
17189
|
await flushText("", true);
|
|
17191
17190
|
if (occurrencesBefore === 0) {
|
|
17192
|
-
throw createGbkError("GBK_NO_MATCH", `\u672A\u627E\u5230\u8981\u66FF\u6362\u7684\u5185\
|
|
17191
|
+
throw createGbkError("GBK_NO_MATCH", `\u672A\u627E\u5230\u8981\u66FF\u6362\u7684\u5185\uFFFD\uFFFD?: ${input.oldString}`);
|
|
17193
17192
|
}
|
|
17194
17193
|
if (!input.replaceAll && occurrencesBefore > 1) {
|
|
17195
|
-
throw createGbkError("GBK_MULTIPLE_MATCHES", `\u627E\u5230\u591A\u4E2A\u5339\u914D\
|
|
17194
|
+
throw createGbkError("GBK_MULTIPLE_MATCHES", `\u627E\u5230\u591A\u4E2A\u5339\u914D\uFFFD\uFFFD?: ${input.oldString}`);
|
|
17196
17195
|
}
|
|
17197
17196
|
await handle.close();
|
|
17198
17197
|
const mode = typeof input.stat.mode === "bigint" ? Number(input.stat.mode) : input.stat.mode;
|
|
@@ -17407,7 +17406,7 @@ async function replaceGbkFileText(input) {
|
|
|
17407
17406
|
occurrencesBefore: loose.occurrencesBefore,
|
|
17408
17407
|
bytesRead: current.bytesRead,
|
|
17409
17408
|
bytesWritten: buffer2.byteLength,
|
|
17410
|
-
diffPreview: buildGbkLineDiffPreview(current.filePath, current.encoding,
|
|
17409
|
+
diffPreview: buildGbkLineDiffPreview(current.filePath, current.encoding, loose.matchedOriginal, input.newString ?? "")
|
|
17411
17410
|
};
|
|
17412
17411
|
}
|
|
17413
17412
|
}
|
|
@@ -17418,7 +17417,7 @@ async function replaceGbkFileText(input) {
|
|
|
17418
17417
|
} else if (occurrencesBefore === 0) {
|
|
17419
17418
|
throw createGbkError("GBK_NO_MATCH", buildNoMatchMessage(scope.selectedText, effectiveOldString));
|
|
17420
17419
|
} else if (occurrencesBefore > 1) {
|
|
17421
|
-
throw createGbkError("GBK_MULTIPLE_MATCHES", `\u627E\u5230\u591A\u4E2A\u5339\u914D\
|
|
17420
|
+
throw createGbkError("GBK_MULTIPLE_MATCHES", `\u627E\u5230\u591A\u4E2A\u5339\u914D\uFFFD\uFFFD?: ${effectiveOldString}`);
|
|
17422
17421
|
}
|
|
17423
17422
|
const fileNewlineStyle = detectNewlineStyle(current.content);
|
|
17424
17423
|
const alignedNewString = fileNewlineStyle === "crlf" ? input.newString.replace(/\r\n/g, "\n").replace(/\n/g, "\r\n") : fileNewlineStyle === "lf" ? input.newString.replace(/\r\n/g, "\n") : input.newString;
|
|
@@ -17551,10 +17550,10 @@ async function writeGbkFile(input) {
|
|
|
17551
17550
|
try {
|
|
17552
17551
|
const stat = await fs2.stat(candidatePath);
|
|
17553
17552
|
if (stat.isDirectory()) {
|
|
17554
|
-
throw createGbkError("GBK_IS_DIRECTORY", `\u76EE\u6807\u8DEF\u5F84\u662F\u76EE\
|
|
17553
|
+
throw createGbkError("GBK_IS_DIRECTORY", `\u76EE\u6807\u8DEF\u5F84\u662F\u76EE\uFFFD\uFFFD?: ${candidatePath}`);
|
|
17555
17554
|
}
|
|
17556
17555
|
if (!overwrite) {
|
|
17557
|
-
throw createGbkError("GBK_FILE_EXISTS", `\u76EE\u6807\u6587\u4EF6\u5DF2\u5B58\
|
|
17556
|
+
throw createGbkError("GBK_FILE_EXISTS", `\u76EE\u6807\u6587\u4EF6\u5DF2\u5B58\uFFFD\uFFFD?: ${candidatePath}`);
|
|
17558
17557
|
}
|
|
17559
17558
|
} catch (error45) {
|
|
17560
17559
|
if (error45 instanceof Error && "code" in error45) {
|
|
@@ -18052,17 +18051,13 @@ function assertInsertArguments2(input) {
|
|
|
18052
18051
|
throw createTextError("GBK_INVALID_ARGUMENT", "\u63D2\u5165\u6A21\u5F0F\u4E0D\u652F\u6301 startLine/endLine/startAnchor/endAnchor");
|
|
18053
18052
|
}
|
|
18054
18053
|
}
|
|
18055
|
-
var ANSI_RED2 = "\x1B[31m";
|
|
18056
|
-
var ANSI_GREEN2 = "\x1B[32m";
|
|
18057
|
-
var ANSI_DIM2 = "\x1B[2m";
|
|
18058
|
-
var ANSI_RESET2 = "\x1B[0m";
|
|
18059
18054
|
function buildLineDiffPreview(filePath, encoding, beforeText, afterText) {
|
|
18060
18055
|
const beforeLines = normalizeNewlines2(beforeText).split("\n");
|
|
18061
18056
|
const afterLines = normalizeNewlines2(afterText).split("\n");
|
|
18062
18057
|
const maxLines = Math.max(beforeLines.length, afterLines.length);
|
|
18063
18058
|
const lines = [
|
|
18064
|
-
|
|
18065
|
-
|
|
18059
|
+
`--- ${path3.basename(filePath)} (${encoding})`,
|
|
18060
|
+
`+++ ${path3.basename(filePath)} (${encoding})`
|
|
18066
18061
|
];
|
|
18067
18062
|
for (let index = 0; index < maxLines; index += 1) {
|
|
18068
18063
|
const before = beforeLines[index];
|
|
@@ -18072,10 +18067,10 @@ function buildLineDiffPreview(filePath, encoding, beforeText, afterText) {
|
|
|
18072
18067
|
continue;
|
|
18073
18068
|
}
|
|
18074
18069
|
if (before !== void 0) {
|
|
18075
|
-
lines.push(
|
|
18070
|
+
lines.push(`-${before}`);
|
|
18076
18071
|
}
|
|
18077
18072
|
if (after !== void 0) {
|
|
18078
|
-
lines.push(
|
|
18073
|
+
lines.push(`+${after}`);
|
|
18079
18074
|
}
|
|
18080
18075
|
}
|
|
18081
18076
|
return lines.join("\n");
|
|
@@ -16308,17 +16308,13 @@ async function assertPathAllowed(filePath, context, allowExternal = false) {
|
|
|
16308
16308
|
var STREAMING_FILE_SIZE_THRESHOLD_BYTES = 1024 * 1024;
|
|
16309
16309
|
var STREAM_READ_CHUNK_SIZE_BYTES = 1024 * 1024;
|
|
16310
16310
|
var gbkLineIndexCache = /* @__PURE__ */ new Map();
|
|
16311
|
-
var ANSI_RED = "\x1B[31m";
|
|
16312
|
-
var ANSI_GREEN = "\x1B[32m";
|
|
16313
|
-
var ANSI_DIM = "\x1B[2m";
|
|
16314
|
-
var ANSI_RESET = "\x1B[0m";
|
|
16315
16311
|
function buildGbkLineDiffPreview(filePath, encoding, beforeText, afterText) {
|
|
16316
16312
|
const beforeLines = normalizeNewlines(beforeText).split("\n");
|
|
16317
16313
|
const afterLines = normalizeNewlines(afterText).split("\n");
|
|
16318
16314
|
const maxLines = Math.max(beforeLines.length, afterLines.length);
|
|
16319
16315
|
const lines = [
|
|
16320
|
-
|
|
16321
|
-
|
|
16316
|
+
`--- ${path2.basename(filePath)} (${encoding})`,
|
|
16317
|
+
`+++ ${path2.basename(filePath)} (${encoding})`
|
|
16322
16318
|
];
|
|
16323
16319
|
for (let index = 0; index < maxLines; index += 1) {
|
|
16324
16320
|
const before = beforeLines[index];
|
|
@@ -16328,10 +16324,10 @@ function buildGbkLineDiffPreview(filePath, encoding, beforeText, afterText) {
|
|
|
16328
16324
|
continue;
|
|
16329
16325
|
}
|
|
16330
16326
|
if (before !== void 0) {
|
|
16331
|
-
lines.push(
|
|
16327
|
+
lines.push(`-${before}`);
|
|
16332
16328
|
}
|
|
16333
16329
|
if (after !== void 0) {
|
|
16334
|
-
lines.push(
|
|
16330
|
+
lines.push(`+${after}`);
|
|
16335
16331
|
}
|
|
16336
16332
|
}
|
|
16337
16333
|
return lines.join("\n");
|
|
@@ -16358,10 +16354,10 @@ function assertInsertArguments(input) {
|
|
|
16358
16354
|
throw createGbkError("GBK_INVALID_ARGUMENT", "content \u4E0D\u80FD\u4E3A\u7A7A");
|
|
16359
16355
|
}
|
|
16360
16356
|
if (input.replaceAll !== void 0) {
|
|
16361
|
-
throw createGbkError("GBK_INVALID_ARGUMENT", "\u63D2\u5165\u6A21\u5F0F\u4E0D\u652F\
|
|
16357
|
+
throw createGbkError("GBK_INVALID_ARGUMENT", "\u63D2\u5165\u6A21\u5F0F\u4E0D\u652F\uFFFD\uFFFD? replaceAll");
|
|
16362
16358
|
}
|
|
16363
16359
|
if (input.startLine !== void 0 || input.endLine !== void 0 || input.startAnchor !== void 0 || input.endAnchor !== void 0) {
|
|
16364
|
-
throw createGbkError("GBK_INVALID_ARGUMENT", "\u63D2\u5165\u6A21\u5F0F\u4E0D\u652F\
|
|
16360
|
+
throw createGbkError("GBK_INVALID_ARGUMENT", "\u63D2\u5165\u6A21\u5F0F\u4E0D\u652F\uFFFD\uFFFD? startLine/endLine/startAnchor/endAnchor");
|
|
16365
16361
|
}
|
|
16366
16362
|
}
|
|
16367
16363
|
function findOccurrenceIndex(text, token, occurrence) {
|
|
@@ -16385,9 +16381,9 @@ function findOccurrenceIndex(text, token, occurrence) {
|
|
|
16385
16381
|
searchFrom = index + token.length;
|
|
16386
16382
|
}
|
|
16387
16383
|
if (count === 0) {
|
|
16388
|
-
throw createGbkError("GBK_NO_MATCH", `\u672A\u627E\u5230\u951A\
|
|
16384
|
+
throw createGbkError("GBK_NO_MATCH", `\u672A\u627E\u5230\u951A\uFFFD\uFFFD?: ${token}`);
|
|
16389
16385
|
}
|
|
16390
|
-
throw createGbkError("GBK_NO_MATCH", `\u951A\u70B9 ${token} \u53EA\u627E\
|
|
16386
|
+
throw createGbkError("GBK_NO_MATCH", `\u951A\u70B9 ${token} \u53EA\u627E\uFFFD\uFFFD? ${count} \u5904\uFF0C\u65E0\u6CD5\u4F7F\u7528\uFFFD\uFFFD? ${occurrence} \u5904`);
|
|
16391
16387
|
}
|
|
16392
16388
|
function insertByAnchor(text, mode, anchor, content, occurrence, ifExists, newlineStyle) {
|
|
16393
16389
|
const alignedContent = newlineStyle === "crlf" ? content.replace(/\r\n/g, "\n").replace(/\n/g, "\r\n") : newlineStyle === "lf" ? content.replace(/\r\n/g, "\n") : content;
|
|
@@ -16396,7 +16392,7 @@ function insertByAnchor(text, mode, anchor, content, occurrence, ifExists, newli
|
|
|
16396
16392
|
const alreadyExists = mode === "insertAfter" ? text.slice(insertionPoint, insertionPoint + alignedContent.length) === alignedContent : text.slice(Math.max(0, insertionPoint - alignedContent.length), insertionPoint) === alignedContent;
|
|
16397
16393
|
if (alreadyExists) {
|
|
16398
16394
|
if (ifExists === "error") {
|
|
16399
|
-
throw createGbkError("GBK_INVALID_ARGUMENT", "\u63D2\u5165\u4F4D\u7F6E\u5DF2\u5B58\u5728\u76F8\u540C\u5185\
|
|
16395
|
+
throw createGbkError("GBK_INVALID_ARGUMENT", "\u63D2\u5165\u4F4D\u7F6E\u5DF2\u5B58\u5728\u76F8\u540C\u5185\uFFFD\uFFFD?");
|
|
16400
16396
|
}
|
|
16401
16397
|
if (ifExists === "skip") {
|
|
16402
16398
|
return {
|
|
@@ -16437,7 +16433,7 @@ function normalizeOptionalPositiveInteger(value, name) {
|
|
|
16437
16433
|
}
|
|
16438
16434
|
function assertNotBinary(buffer) {
|
|
16439
16435
|
if (buffer.includes(0)) {
|
|
16440
|
-
throw createGbkError("GBK_BINARY_FILE", "\u7591\u4F3C\u4E8C\u8FDB\u5236\u6587\u4EF6\uFF0C\u65E0\u6CD5\
|
|
16436
|
+
throw createGbkError("GBK_BINARY_FILE", "\u7591\u4F3C\u4E8C\u8FDB\u5236\u6587\u4EF6\uFF0C\u65E0\u6CD5\uFFFD\uFFFD? GBK \u6587\u672C\u5904\u7406");
|
|
16441
16437
|
}
|
|
16442
16438
|
}
|
|
16443
16439
|
function splitLinesWithNumbers(text, offset = 1, limit = 2e3) {
|
|
@@ -16567,14 +16563,14 @@ function applyAnchors(text, startAnchor, endAnchor) {
|
|
|
16567
16563
|
if (startAnchor) {
|
|
16568
16564
|
const found = text.indexOf(startAnchor);
|
|
16569
16565
|
if (found === -1) {
|
|
16570
|
-
throw createGbkError("GBK_NO_MATCH", `\u672A\u627E\u5230\u8D77\u59CB\u951A\
|
|
16566
|
+
throw createGbkError("GBK_NO_MATCH", `\u672A\u627E\u5230\u8D77\u59CB\u951A\uFFFD\uFFFD?: ${startAnchor}`);
|
|
16571
16567
|
}
|
|
16572
16568
|
rangeStart = found + startAnchor.length;
|
|
16573
16569
|
}
|
|
16574
16570
|
if (endAnchor) {
|
|
16575
16571
|
const found = text.indexOf(endAnchor, rangeStart);
|
|
16576
16572
|
if (found === -1) {
|
|
16577
|
-
throw createGbkError("GBK_NO_MATCH", `\u672A\u627E\u5230\u7ED3\u675F\u951A\
|
|
16573
|
+
throw createGbkError("GBK_NO_MATCH", `\u672A\u627E\u5230\u7ED3\u675F\u951A\uFFFD\uFFFD?: ${endAnchor}`);
|
|
16578
16574
|
}
|
|
16579
16575
|
rangeEnd = found;
|
|
16580
16576
|
}
|
|
@@ -16627,9 +16623,9 @@ function getNearestContext(content, oldString) {
|
|
|
16627
16623
|
}
|
|
16628
16624
|
function buildNoMatchMessage(content, oldString) {
|
|
16629
16625
|
return [
|
|
16630
|
-
"\u672A\u627E\u5230\u9700\u8981\u66FF\u6362\u7684\u6587\u672C\
|
|
16631
|
-
"oldString \u5FC5\u987B\u4E0E\u6587\u4EF6\u5B9E\u9645\u5185\u5BB9\u5B8C\u5168\u5BF9\u5E94\uFF0C\u6216\u4EC5\u5728\u6362\
|
|
16632
|
-
"\u6700\u63A5\u8FD1\u7684\u4E0A\u4E0B\u6587\
|
|
16626
|
+
"\u672A\u627E\u5230\u9700\u8981\u66FF\u6362\u7684\u6587\u672C\uFFFD\uFFFD?",
|
|
16627
|
+
"oldString \u5FC5\u987B\u4E0E\u6587\u4EF6\u5B9E\u9645\u5185\u5BB9\u5B8C\u5168\u5BF9\u5E94\uFF0C\u6216\u4EC5\u5728\u6362\uFFFD\uFFFD?/\u5C3E\u968F\u7A7A\u884C\u4E0A\u5B58\u5728\u8F7B\u5FAE\u5DEE\u5F02\uFFFD\uFFFD?",
|
|
16628
|
+
"\u6700\u63A5\u8FD1\u7684\u4E0A\u4E0B\u6587\uFFFD\uFFFD?",
|
|
16633
16629
|
getNearestContext(content, oldString)
|
|
16634
16630
|
].join("\n");
|
|
16635
16631
|
}
|
|
@@ -16686,6 +16682,8 @@ function matchLooseBlock(contentLines, oldLines, newLines, newlineStyle, content
|
|
|
16686
16682
|
break;
|
|
16687
16683
|
}
|
|
16688
16684
|
if (oldIndex === oldLines.length) {
|
|
16685
|
+
const matchedLines = contentLines.slice(start, contentIndex);
|
|
16686
|
+
const matchedOriginal = matchedLines.join("\n");
|
|
16689
16687
|
const replacedNormalized = [
|
|
16690
16688
|
...contentLines.slice(0, start),
|
|
16691
16689
|
...newLines,
|
|
@@ -16693,6 +16691,7 @@ function matchLooseBlock(contentLines, oldLines, newLines, newlineStyle, content
|
|
|
16693
16691
|
].join("\n");
|
|
16694
16692
|
return {
|
|
16695
16693
|
occurrencesBefore: 1,
|
|
16694
|
+
matchedOriginal,
|
|
16696
16695
|
content: newlineStyle === "crlf" ? replacedNormalized.replace(/\n/g, "\r\n") : replacedNormalized
|
|
16697
16696
|
};
|
|
16698
16697
|
}
|
|
@@ -16749,10 +16748,10 @@ async function resolveReadableGbkFile(input) {
|
|
|
16749
16748
|
try {
|
|
16750
16749
|
stat = await fs2.stat(candidatePath);
|
|
16751
16750
|
} catch (error45) {
|
|
16752
|
-
throw createGbkError("GBK_FILE_NOT_FOUND", `\u6587\u4EF6\u4E0D\u5B58\
|
|
16751
|
+
throw createGbkError("GBK_FILE_NOT_FOUND", `\u6587\u4EF6\u4E0D\u5B58\uFFFD\uFFFD?: ${candidatePath}`, error45);
|
|
16753
16752
|
}
|
|
16754
16753
|
if (stat.isDirectory()) {
|
|
16755
|
-
throw createGbkError("GBK_IS_DIRECTORY", `\u76EE\u6807\u8DEF\u5F84\u662F\u76EE\
|
|
16754
|
+
throw createGbkError("GBK_IS_DIRECTORY", `\u76EE\u6807\u8DEF\u5F84\u662F\u76EE\uFFFD\uFFFD?: ${candidatePath}`);
|
|
16756
16755
|
}
|
|
16757
16756
|
return {
|
|
16758
16757
|
filePath: candidatePath,
|
|
@@ -16957,7 +16956,7 @@ function replaceScopedTextContent(scopeText, oldString, newString, replaceAll, n
|
|
|
16957
16956
|
} else if (occurrencesBefore === 0) {
|
|
16958
16957
|
throw createGbkError("GBK_NO_MATCH", buildNoMatchMessage(scopeText, oldString));
|
|
16959
16958
|
} else if (occurrencesBefore > 1) {
|
|
16960
|
-
throw createGbkError("GBK_MULTIPLE_MATCHES", `\u627E\u5230\u591A\u4E2A\u5339\u914D\
|
|
16959
|
+
throw createGbkError("GBK_MULTIPLE_MATCHES", `\u627E\u5230\u591A\u4E2A\u5339\u914D\uFFFD\uFFFD?: ${oldString}`);
|
|
16961
16960
|
}
|
|
16962
16961
|
const alignedNewString = alignTextToNewlineStyle(newString, newlineStyle);
|
|
16963
16962
|
return {
|
|
@@ -17062,7 +17061,7 @@ async function replaceLargeGbkFileByAnchor(input) {
|
|
|
17062
17061
|
const alreadyExists = input.mode === "insertAfter" ? after.startsWith(alignedContent) : before.endsWith(alignedContent);
|
|
17063
17062
|
if (alreadyExists) {
|
|
17064
17063
|
if (input.ifExists === "error") {
|
|
17065
|
-
throw createGbkError("GBK_INVALID_ARGUMENT", "\u63D2\u5165\u4F4D\u7F6E\u5DF2\u5B58\u5728\u76F8\u540C\u5185\
|
|
17064
|
+
throw createGbkError("GBK_INVALID_ARGUMENT", "\u63D2\u5165\u4F4D\u7F6E\u5DF2\u5B58\u5728\u76F8\u540C\u5185\uFFFD\uFFFD?");
|
|
17066
17065
|
}
|
|
17067
17066
|
if (input.ifExists === "skip") {
|
|
17068
17067
|
skipped = true;
|
|
@@ -17109,7 +17108,7 @@ async function replaceLargeGbkFileByAnchor(input) {
|
|
|
17109
17108
|
const alreadyExists = input.mode === "insertAfter" ? after.startsWith(alignedContent) : before.endsWith(alignedContent);
|
|
17110
17109
|
if (alreadyExists) {
|
|
17111
17110
|
if (input.ifExists === "error") {
|
|
17112
|
-
throw createGbkError("GBK_INVALID_ARGUMENT", "\u63D2\u5165\u4F4D\u7F6E\u5DF2\u5B58\u5728\u76F8\u540C\u5185\
|
|
17111
|
+
throw createGbkError("GBK_INVALID_ARGUMENT", "\u63D2\u5165\u4F4D\u7F6E\u5DF2\u5B58\u5728\u76F8\u540C\u5185\uFFFD\uFFFD?");
|
|
17113
17112
|
}
|
|
17114
17113
|
if (input.ifExists === "skip") {
|
|
17115
17114
|
skipped = true;
|
|
@@ -17123,10 +17122,10 @@ async function replaceLargeGbkFileByAnchor(input) {
|
|
|
17123
17122
|
}
|
|
17124
17123
|
}
|
|
17125
17124
|
if (!inserted && totalMatches === 0) {
|
|
17126
|
-
throw createGbkError("GBK_NO_MATCH", `\u672A\u627E\u5230\u951A\
|
|
17125
|
+
throw createGbkError("GBK_NO_MATCH", `\u672A\u627E\u5230\u951A\uFFFD\uFFFD?: ${input.anchor}`);
|
|
17127
17126
|
}
|
|
17128
17127
|
if (!inserted && totalMatches > 0) {
|
|
17129
|
-
throw createGbkError("GBK_NO_MATCH", `\u951A\u70B9 ${input.anchor} \u53EA\u627E\
|
|
17128
|
+
throw createGbkError("GBK_NO_MATCH", `\u951A\u70B9 ${input.anchor} \u53EA\u627E\uFFFD\uFFFD? ${totalMatches} \u5904\uFF0C\u65E0\u6CD5\u4F7F\u7528\uFFFD\uFFFD? ${input.occurrence} \u5904`);
|
|
17130
17129
|
}
|
|
17131
17130
|
await finalizeInserted();
|
|
17132
17131
|
await handle.close();
|
|
@@ -17189,10 +17188,10 @@ async function replaceLargeGbkFileText(input) {
|
|
|
17189
17188
|
});
|
|
17190
17189
|
await flushText("", true);
|
|
17191
17190
|
if (occurrencesBefore === 0) {
|
|
17192
|
-
throw createGbkError("GBK_NO_MATCH", `\u672A\u627E\u5230\u8981\u66FF\u6362\u7684\u5185\
|
|
17191
|
+
throw createGbkError("GBK_NO_MATCH", `\u672A\u627E\u5230\u8981\u66FF\u6362\u7684\u5185\uFFFD\uFFFD?: ${input.oldString}`);
|
|
17193
17192
|
}
|
|
17194
17193
|
if (!input.replaceAll && occurrencesBefore > 1) {
|
|
17195
|
-
throw createGbkError("GBK_MULTIPLE_MATCHES", `\u627E\u5230\u591A\u4E2A\u5339\u914D\
|
|
17194
|
+
throw createGbkError("GBK_MULTIPLE_MATCHES", `\u627E\u5230\u591A\u4E2A\u5339\u914D\uFFFD\uFFFD?: ${input.oldString}`);
|
|
17196
17195
|
}
|
|
17197
17196
|
await handle.close();
|
|
17198
17197
|
const mode = typeof input.stat.mode === "bigint" ? Number(input.stat.mode) : input.stat.mode;
|
|
@@ -17407,7 +17406,7 @@ async function replaceGbkFileText(input) {
|
|
|
17407
17406
|
occurrencesBefore: loose.occurrencesBefore,
|
|
17408
17407
|
bytesRead: current.bytesRead,
|
|
17409
17408
|
bytesWritten: buffer2.byteLength,
|
|
17410
|
-
diffPreview: buildGbkLineDiffPreview(current.filePath, current.encoding,
|
|
17409
|
+
diffPreview: buildGbkLineDiffPreview(current.filePath, current.encoding, loose.matchedOriginal, input.newString ?? "")
|
|
17411
17410
|
};
|
|
17412
17411
|
}
|
|
17413
17412
|
}
|
|
@@ -17418,7 +17417,7 @@ async function replaceGbkFileText(input) {
|
|
|
17418
17417
|
} else if (occurrencesBefore === 0) {
|
|
17419
17418
|
throw createGbkError("GBK_NO_MATCH", buildNoMatchMessage(scope.selectedText, effectiveOldString));
|
|
17420
17419
|
} else if (occurrencesBefore > 1) {
|
|
17421
|
-
throw createGbkError("GBK_MULTIPLE_MATCHES", `\u627E\u5230\u591A\u4E2A\u5339\u914D\
|
|
17420
|
+
throw createGbkError("GBK_MULTIPLE_MATCHES", `\u627E\u5230\u591A\u4E2A\u5339\u914D\uFFFD\uFFFD?: ${effectiveOldString}`);
|
|
17422
17421
|
}
|
|
17423
17422
|
const fileNewlineStyle = detectNewlineStyle(current.content);
|
|
17424
17423
|
const alignedNewString = fileNewlineStyle === "crlf" ? input.newString.replace(/\r\n/g, "\n").replace(/\n/g, "\r\n") : fileNewlineStyle === "lf" ? input.newString.replace(/\r\n/g, "\n") : input.newString;
|
|
@@ -17551,10 +17550,10 @@ async function writeGbkFile(input) {
|
|
|
17551
17550
|
try {
|
|
17552
17551
|
const stat = await fs2.stat(candidatePath);
|
|
17553
17552
|
if (stat.isDirectory()) {
|
|
17554
|
-
throw createGbkError("GBK_IS_DIRECTORY", `\u76EE\u6807\u8DEF\u5F84\u662F\u76EE\
|
|
17553
|
+
throw createGbkError("GBK_IS_DIRECTORY", `\u76EE\u6807\u8DEF\u5F84\u662F\u76EE\uFFFD\uFFFD?: ${candidatePath}`);
|
|
17555
17554
|
}
|
|
17556
17555
|
if (!overwrite) {
|
|
17557
|
-
throw createGbkError("GBK_FILE_EXISTS", `\u76EE\u6807\u6587\u4EF6\u5DF2\u5B58\
|
|
17556
|
+
throw createGbkError("GBK_FILE_EXISTS", `\u76EE\u6807\u6587\u4EF6\u5DF2\u5B58\uFFFD\uFFFD?: ${candidatePath}`);
|
|
17558
17557
|
}
|
|
17559
17558
|
} catch (error45) {
|
|
17560
17559
|
if (error45 instanceof Error && "code" in error45) {
|
|
@@ -18052,17 +18051,13 @@ function assertInsertArguments2(input) {
|
|
|
18052
18051
|
throw createTextError("GBK_INVALID_ARGUMENT", "\u63D2\u5165\u6A21\u5F0F\u4E0D\u652F\u6301 startLine/endLine/startAnchor/endAnchor");
|
|
18053
18052
|
}
|
|
18054
18053
|
}
|
|
18055
|
-
var ANSI_RED2 = "\x1B[31m";
|
|
18056
|
-
var ANSI_GREEN2 = "\x1B[32m";
|
|
18057
|
-
var ANSI_DIM2 = "\x1B[2m";
|
|
18058
|
-
var ANSI_RESET2 = "\x1B[0m";
|
|
18059
18054
|
function buildLineDiffPreview(filePath, encoding, beforeText, afterText) {
|
|
18060
18055
|
const beforeLines = normalizeNewlines2(beforeText).split("\n");
|
|
18061
18056
|
const afterLines = normalizeNewlines2(afterText).split("\n");
|
|
18062
18057
|
const maxLines = Math.max(beforeLines.length, afterLines.length);
|
|
18063
18058
|
const lines = [
|
|
18064
|
-
|
|
18065
|
-
|
|
18059
|
+
`--- ${path3.basename(filePath)} (${encoding})`,
|
|
18060
|
+
`+++ ${path3.basename(filePath)} (${encoding})`
|
|
18066
18061
|
];
|
|
18067
18062
|
for (let index = 0; index < maxLines; index += 1) {
|
|
18068
18063
|
const before = beforeLines[index];
|
|
@@ -18072,10 +18067,10 @@ function buildLineDiffPreview(filePath, encoding, beforeText, afterText) {
|
|
|
18072
18067
|
continue;
|
|
18073
18068
|
}
|
|
18074
18069
|
if (before !== void 0) {
|
|
18075
|
-
lines.push(
|
|
18070
|
+
lines.push(`-${before}`);
|
|
18076
18071
|
}
|
|
18077
18072
|
if (after !== void 0) {
|
|
18078
|
-
lines.push(
|
|
18073
|
+
lines.push(`+${after}`);
|
|
18079
18074
|
}
|
|
18080
18075
|
}
|
|
18081
18076
|
return lines.join("\n");
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"manifestVersion": 1,
|
|
3
3
|
"packageName": "opencode-gbk-tools",
|
|
4
|
-
"packageVersion": "0.1.
|
|
4
|
+
"packageVersion": "0.1.21",
|
|
5
5
|
"artifacts": [
|
|
6
6
|
{
|
|
7
7
|
"relativePath": "plugins/opencode-gbk-tools.js",
|
|
8
8
|
"kind": "plugin",
|
|
9
|
-
"expectedHash": "
|
|
9
|
+
"expectedHash": "d0407b86c21d2515bf4642c3bbede9bc26083224d316f19c3d40decb7fea4461",
|
|
10
10
|
"hashAlgorithm": "sha256"
|
|
11
11
|
}
|
|
12
12
|
]
|