Skip to content

Commit 5341d1c

Browse files
mmahroussfda-odoo
authored andcommitted
[FIX] avoid stripping extension from dir paths
1 parent ef08fdb commit 5341d1c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

server/src/core/symbols/symbol.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1288,7 +1288,11 @@ impl Symbol {
12881288

12891289
///Given a path, create the appropriated symbol and attach it to the given parent
12901290
pub fn create_from_path(session: &mut SessionInfo, path: &PathBuf, parent: Rc<RefCell<Symbol>>, require_module: bool) -> Option<Rc<RefCell<Symbol>>> {
1291-
let name: String = path.with_extension("").components().last().unwrap().as_os_str().to_str().unwrap().to_string();
1291+
let name: String = if path.is_dir() {
1292+
path.components().last().unwrap().as_os_str().to_str().unwrap().to_string()
1293+
} else {
1294+
path.with_extension("").components().last().unwrap().as_os_str().to_str().unwrap().to_string()
1295+
};
12921296
let path_str = path.sanitize();
12931297
if path_str.ends_with(".py") || path_str.ends_with(".pyi") {
12941298
return Some(parent.borrow_mut().add_new_file(session, &name, &path_str));

0 commit comments

Comments
 (0)