From a088bbbbd0eed36b9b4eb3d39dc9bc306d33f185 Mon Sep 17 00:00:00 2001 From: A Farzat Date: Sun, 7 Jun 2026 21:15:45 +0300 Subject: Prioritize detection through extensions While shebangs take priority on Unix-like systems, the shebang detection here is very basic and not guaranteed to be correct, so its use should be secondary. --- src/util/language.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/util/language.rs b/src/util/language.rs index 8da45b8..f0870c8 100644 --- a/src/util/language.rs +++ b/src/util/language.rs @@ -63,4 +63,10 @@ mod tests { let contents = "#!/usr/bin/env sh\necho hi"; assert_eq!(detect_language(Path::new("file"), contents), "bash"); } + + #[test] + fn extension_overrides_shebang() { + let contents = "#!/bin/bash\nprint('hello')"; + assert_eq!(detect_language(Path::new("main.py"), contents), "python"); + } } -- cgit v1.3.1