Skip to content

Commit 3091b33

Browse files
committed
fix:兼容多余空格的模糊匹配
1 parent 14927f2 commit 3091b33

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/cvbManager.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,8 +648,15 @@ function escapeRegExp(str: string) : string
648648
function normalizeLineWhitespace(anchor: string): string {
649649
return anchor.split('\n')
650650
.map(line => {
651-
// 对每一行的空白字符做更精确的处理
652-
return `\\s*${line.trim()}\\s*`; // 保留行首和行尾的空白字符处理
651+
line = line.trim();
652+
if (line.length > 0){
653+
line = line.replace(/\s+/g, '\\s*');
654+
line = `\\s*${line}\\s*`;
655+
}
656+
else{
657+
line = "\\s*";
658+
}
659+
return line; // 保留行首和行尾的空白字符处理
653660
})
654661
.join('\n'); // 行与行之间允许有空白字符(空格、换行符等)
655662
}

0 commit comments

Comments
 (0)