Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/languages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ pub fn language_by_filename(path: &Path) -> Option<Arc<Language>> {
"cpp" | "cxx" | "cc" | "h" | "hh" => language_by_name("cpp"),
"sh" | "zsh" | "bash" => language_by_name("shell"),
"cs" => language_by_name("csharp"),
"html" => language_by_name("html"),
"html" | "htm" => language_by_name("html"),
"css" => language_by_name("css"),
"c" => language_by_name("c"),
"json" => language_by_name("json"),
Expand Down
22 changes: 21 additions & 1 deletion crates/languages/src/lib_tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use crate::{load_language, SUPPORTED_LANGUAGES};
use std::path::Path;

use crate::{language_by_filename, load_language, SUPPORTED_LANGUAGES};

/// Validate that every supported language can be loaded successfully.
/// This catches invalid node types, syntax errors, and other issues in .scm query files
Expand All @@ -20,3 +22,21 @@ fn all_supported_languages_load_successfully() {
.join("\n")
);
}

/// Both `.html` and the legacy three-character `.htm` extension should resolve to
/// the same HTML language entry. `.htm` is widely produced by static-site generators
/// and historical web tooling (DOS 8.3 filename limits) and is already treated as
/// an HTML/text file elsewhere in the codebase
/// (see `is_development_text_extension` in `crates/warp_util/src/file_type.rs`).
#[test]
fn html_extensions_resolve_to_html() {
for filename in ["index.html", "index.htm"] {
let language = language_by_filename(Path::new(filename))
.unwrap_or_else(|| panic!("expected {filename} to resolve to a language"));
assert_eq!(
language.display_name(),
"HTML",
"{filename} should resolve to HTML",
);
}
}
Loading