Skip to content

Commit e976991

Browse files
committed
fix:修复多种代码后缀名支持
1 parent d48080d commit e976991

File tree

3 files changed

+29
-23
lines changed

3 files changed

+29
-23
lines changed

src/cvbManager.ts

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,7 @@ import * as iconv from 'iconv-lite'; // 编码转换库
55
import * as vscode from 'vscode';
66
import { generateFilenameFromRequest } from './deepseekApi';
77

8-
// 语言映射表
9-
const g_objLanguageMapping: { [key: string]: string } = {
10-
'cpp': 'c++',
11-
'hpp': 'c++',
12-
'h': 'c++',
13-
'lua': 'lua',
14-
'ls': 'lua',
15-
'lh': 'lua',
16-
'py': 'python',
17-
'ts': 'typescript',
18-
'js': 'javascript',
19-
'cs': 'c#', // C#
20-
'java': 'java', // Java
21-
'go': 'go', // Go
22-
'rb': 'ruby', // Ruby
23-
'swift': 'swift', // Swift
24-
'kt': 'kotlin', // Kotlin
25-
'php': 'php', // PHP
26-
'rust': 'rust', // Rust
27-
'dart': 'dart' // Dart
28-
};
8+
import { g_objLanguageMapping } from './languageMapping';
299

3010
// ================== CVB 核心类 ==================
3111
export class Cvb
@@ -880,4 +860,4 @@ export function applyCvbToWorkspace(strCvbContent: string) : void
880860
fs.writeFileSync(strAbsoluteFilePath, strFileContent, 'utf-8');
881861
}
882862
vscode.window.showInformationMessage('CVB applied successfully!');
883-
}
863+
}

src/fileSelector.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import * as vscode from 'vscode';
22

3+
import { g_objLanguageMapping } from './languageMapping';
4+
35
// 配置常量
46
const ALLOWED_FILENAMES = ['package.json']; // 文件名白名单
5-
const INCLUDED_EXTENSIONS = ['cpp', 'h', 'c', 'cxx', 'hpp', 'py', 'lua', 'ls', 'lh', 'ts', 'js', "md"]; // 扩展名白名单
7+
const INCLUDED_EXTENSIONS = Object.keys(g_objLanguageMapping); // 扩展名白名单
68
const EXCLUDED_DIRECTORIES = ['node_modules', '.git', 'build', 'dist', 'out', 'vendor']; // 排除目录
79

810
/**

src/languageMapping.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// 语言映射表
2+
export const g_objLanguageMapping: { [key: string]: string } = {
3+
'cpp': 'c++',
4+
'hpp': 'c++',
5+
'cxx': 'c++',
6+
'c': 'c',
7+
'h': 'c++',
8+
'lua': 'lua',
9+
'ls': 'lua',
10+
'lh': 'lua',
11+
'py': 'python',
12+
'ts': 'typescript',
13+
'js': 'javascript',
14+
'cs': 'c#', // C#
15+
'java': 'java', // Java
16+
'go': 'go', // Go
17+
'rb': 'ruby', // Ruby
18+
'swift': 'swift', // Swift
19+
'kt': 'kotlin', // Kotlin
20+
'php': 'php', // PHP
21+
'rust': 'rust', // Rust
22+
'dart': 'dart', // Dart
23+
'md': 'markdown' // markdown
24+
};

0 commit comments

Comments
 (0)