Visual Studio Code, rebuilt in Rust
Rust
fix(windows): match language associations against slash paths
rokarturca232f8a2ec8
diff --git a/native/crates/app/src/languages.rs b/native/crates/app/src/languages.rsindex edf1d8772a7..7b724e7ad68 100644--- a/native/crates/app/src/languages.rs+++ b/native/crates/app/src/languages.rs@@ -255,7 +255,7 @@ impl Languages {/// `guessLanguageIdByFilepathOrFirstLine`: `None` when no association matches.pub fn guess_language<'a>(&'a self, path: &Path, first_line: &str) -> Option<&'a str> {- let path = path.to_string_lossy().to_lowercase();+ let path = resource_path(path);let filename = path.rsplit('/').next().unwrap_or(&path);let mut pattern_match: Option<&Association> = None;let mut extension_match: Option<&Association> = None;@@ -290,7 +290,7 @@ impl Languages {/// The `files.associations` language of a path (`userConfigured` associations): the longest pattern that/// matches, against the whole path when the pattern has a `/`, else the file name, ignoring case.pub fn configured_language(associations: &Value, path: &Path) -> Option<String> {- let path = path.to_string_lossy().to_lowercase();+ let path = resource_path(path);let filename = path.rsplit('/').next().unwrap_or(&path);let mut best: Option<(&str, &str)> = None;for (pattern, id) in associations.as_object()? {@@ -404,6 +404,12 @@ impl Languages {}}+/// languagesAssociations.ts matches against the URI's path, lowercased: slashes on Windows too.+fn resource_path(path: &Path) -> String {+ let path = path.to_string_lossy().to_lowercase();+ if cfg!(windows) { path.replace('\\', "/") } else { path }+}+/// languageService.ts `isValidLanguageExtensionPoint`: why the contributed language is rejected.fn language_reject(language: &Value) -> Option<String> {if !crate::contextkey::truthy(Some(language)) {