@@ -5,7 +5,7 @@ import * as iconv from 'iconv-lite'; // 编码转换库
55import * as vscode from 'vscode' ;
66import { generateFilenameFromRequest } from './deepseekApi' ;
77
8- import { g_objLanguageMapping } from './languageMapping' ;
8+ import { getLanguageFromPath } from './languageMapping' ;
99
1010// ================== CVB 核心类 ==================
1111export class Cvb
@@ -56,8 +56,8 @@ export class Cvb
5656 // 将文件内容转换成字符串
5757 let filesStr = '' ;
5858 for ( const filePath in this . m_recFiles ) {
59- // 这里假设文件内容不需要包裹代码块标记,如果需要,可自行添加
60- filesStr += `## FILE:${ filePath } \n${ this . m_recFiles [ filePath ] } \n` ;
59+ const strLang = getLanguageFromPath ( filePath ) ;
60+ filesStr += `## FILE:${ filePath } \n\`\`\` ${ strLang } \n ${ this . m_recFiles [ filePath ] } \n\`\`\` \n` ;
6161 }
6262
6363 // 重新组装整个 CVB 内容
@@ -655,8 +655,7 @@ function rebuildCvb(baseCvb: Cvb, mapFiles: Map<string, string>) : Cvb
655655
656656 for ( const [ strFilePath , strContent ] of mapFiles )
657657 {
658- const strExt : string = path . extname ( strFilePath ) . slice ( 1 ) . toLowerCase ( ) ;
659- const strLang : string = g_objLanguageMapping [ strExt ] || 'text' ;
658+ const strLang : string = getLanguageFromPath ( strFilePath ) ;
660659 strNewContent += `## FILE:${ strFilePath } \n\`\`\`${ strLang } \n${ strContent } \n\`\`\`\n\n` ;
661660 }
662661
@@ -798,8 +797,7 @@ export async function generateCvb(arrFilePaths: string[], strUserRequest: string
798797 try
799798 {
800799 const strFileContent = readFileWithEncoding ( strFilePath ) ;
801- const strExt = path . extname ( strFilePath ) . slice ( 1 ) . toLowerCase ( ) ;
802- const strLang = g_objLanguageMapping [ strExt ] || 'text' ;
800+ const strLang = getLanguageFromPath ( strFilePath ) ;
803801 strCvbContent += `## FILE:${ strFilePath } \n` ;
804802 strCvbContent += '```' + strLang + '\n' ;
805803 strCvbContent += strFileContent + '\n' ;
0 commit comments