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:
1 parent
9b496a7b03
commit
910bde692a
11 files changed
+139
-8
No files matched your search
+2
-2
@@ -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(|_| ())
|
||||
|
||||
Reference in new issue
Block a user