Import files from folders above: import ..a.b, import ...a.b

Leading dots go up one folder less than their count (.. is one up, ...
is two). The language server index and formatter understand them, and a
missing file is reported with its real path.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Your NameandClaude Sonnet 5.5 committed 2026-11-08 23:54:11 +01:00
1 parent 9b496a7b03
commit 910bde692a
11 files changed
+139 -8

No files matched your search

+2 -2
View File
@@ -91,7 +91,7 @@ pub fn compile_file(path: &str) -> Result<String, String> {
let src = std::fs::read_to_string(path).map_err(|e| format!("error: cannot read {path}: {e}"))?;
let dir = Path::new(path).parent().map(Path::to_path_buf).unwrap_or_default();
compile_project(path, &src, |key| {
let file = dir.join(format!("{}.rex", key.replace('.', "/")));
let file = dir.join(loader::key_file(key));
std::fs::read_to_string(&file).ok().map(|s| (file.display().to_string(), s))
})
}
@@ -102,7 +102,7 @@ pub fn check_file(path: &str) -> Result<(), String> {
let src = std::fs::read_to_string(path).map_err(|e| format!("error: cannot read {path}: {e}"))?;
let dir = Path::new(path).parent().map(Path::to_path_buf).unwrap_or_default();
let read = |key: &str| {
let file = dir.join(format!("{}.rex", key.replace('.', "/")));
let file = dir.join(loader::key_file(key));
std::fs::read_to_string(&file).ok().map(|s| (file.display().to_string(), s))
};
check_project(path, &src, read, true).map(|_| ())