Add glob support for custom file type language (#12043)
Release Notes: - Added glob support for file_types configuration ([#10765](https://github.com/zed-industries/zed/issues/10765)). `file_types` can now be written like this: ```json "file_types": { "Dockerfile": [ "Dockerfile", "Dockerfile.*", ] } ```
This commit is contained in:
parent
4e935f9f0f
commit
ab7ce32888
4 changed files with 39 additions and 15 deletions
|
@ -184,6 +184,10 @@ async fn test_language_for_file_with_custom_file_types(cx: &mut TestAppContext)
|
|||
settings.file_types.extend([
|
||||
("TypeScript".into(), vec!["js".into()]),
|
||||
("C++".into(), vec!["c".into()]),
|
||||
(
|
||||
"Dockerfile".into(),
|
||||
vec!["Dockerfile".into(), "Dockerfile.*".into()],
|
||||
),
|
||||
]);
|
||||
})
|
||||
});
|
||||
|
@ -223,6 +227,14 @@ async fn test_language_for_file_with_custom_file_types(cx: &mut TestAppContext)
|
|||
},
|
||||
..Default::default()
|
||||
},
|
||||
LanguageConfig {
|
||||
name: "Dockerfile".into(),
|
||||
matcher: LanguageMatcher {
|
||||
path_suffixes: vec!["Dockerfile".to_string()],
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
},
|
||||
] {
|
||||
languages.add(Arc::new(Language::new(config, None)));
|
||||
}
|
||||
|
@ -237,6 +249,11 @@ async fn test_language_for_file_with_custom_file_types(cx: &mut TestAppContext)
|
|||
.await
|
||||
.unwrap();
|
||||
assert_eq!(language.name().as_ref(), "C++");
|
||||
let language = cx
|
||||
.read(|cx| languages.language_for_file(&file("Dockerfile.dev"), None, cx))
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(language.name().as_ref(), "Dockerfile");
|
||||
}
|
||||
|
||||
fn file(path: &str) -> Arc<dyn File> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue