Skip to content

Commit 8bf4034

Browse files
committed
fix:修正TCVB的解析正则表达式
1 parent b58677e commit 8bf4034

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/cvbManager.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ export class TCVB
276276
const strFilePath: string = filePathNormalize(arrFileMatch[1]);
277277
const strOperationsBlock: string = arrFileMatch[2];
278278
// 支持操作类型中含有 "-" 符号(如 single-replace 等)
279-
const regOperation: RegExp = /^## OPERATION:([\w-]+)\n([\s\S]*?)(?=^## OPERATION:)/gm;
279+
const regOperation: RegExp = /^## OPERATION:([\w-]+)\n([\s\S]*?)(?=^## OPERATION:|(?![\s\S]))/gm;
280280
let arrOpMatch: RegExpExecArray | null;
281281
while ((arrOpMatch = regOperation.exec(strOperationsBlock)) !== null)
282282
{
@@ -488,10 +488,9 @@ TCVB 格式规范:
488488
[代码块:直接跟正文内容,表示新文件的全部内容]
489489
490490
注意:
491-
1. 文件路径复用:同一文件下的多个操作共享 FILE 声明
492-
2. 混合操作:允许在文件块内任意顺序组合操作类型
493-
3. 锚点为连续的多行内容:使用至少3行唯一文本作为锚点,用来标定范围,防止混淆
494-
4. 代码块用 markdown 格式包裹
491+
1. 文件路径复用:同一文件下## FILE ,可以有多个## OPERATION,不用每次重复相同的## FILE
492+
2. 锚点为连续的多行内容:使用至少3行唯一文本作为锚点,用来标定范围,防止混淆
493+
3. 代码块,(规则中的[代码块:...]) 用 markdown 格式包裹
495494
`;
496495
}
497496
}

src/siderBar.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ async function uploadThisCvb(filePath: string) {
170170
}
171171
const workspacePath = workspaceFolders[0].uri.fsPath;
172172
const filepath = path.join(workspacePath, "/prompt/testdata.txt");
173-
const tcvbContent = fs.readFileSync(filepath, 'utf-8');
173+
let tcvbContent = fs.readFileSync(filepath, 'utf-8');
174+
tcvbContent = tcvbContent.replace(/\r\n?/g, "\n");
174175
const tcvb = new TCVB(tcvbContent);
175176
const cvbContent = fs.readFileSync(filePath, 'utf-8');
176177
const oldCvb = new Cvb(cvbContent);

0 commit comments

Comments
 (0)