This commit is contained in:
LZX committed 2026-09-18 20:40:36 +08:00
1 parent 3df0cbc7c0
commit 4614825b7f
30 files changed
+3226 -158

No files matched your search

+18 -5
View File
@@ -140,16 +140,29 @@ class LspConfigService extends ChangeNotifier {
notifyListeners();
}
/// 根据文件扩展名查找匹配的已启用语言配置
LspLanguageConfig? findByExtension(String ext) {
/// 根据文件扩展名或特殊文件名查找匹配的已启用语言配置
LspLanguageConfig? findByExtension(String ext, {String? filename}) {
final cleanName = filename?.trim().toLowerCase();
if (cleanName != null && cleanName.isNotEmpty) {
for (final config in _configs) {
for (final item in config.fileExtensions) {
if (!item.startsWith('.') && item.toLowerCase() == cleanName) {
return config.enabled ? config : null;
}
}
}
}
if (ext.isEmpty) return null;
final normalized = ext.startsWith('.') ? ext.toLowerCase() : '.$ext'.toLowerCase();
for (final config in _configs) {
for (final item in config.fileExtensions) {
final itemNorm = item.startsWith('.') ? item.toLowerCase() : '.$item'.toLowerCase();
if (itemNorm == normalized) {
return config.enabled ? config : null;
if (item.startsWith('.')) {
final itemNorm = item.toLowerCase();
if (itemNorm == normalized) {
return config.enabled ? config : null;
}
}
}
}