emulator: imports work relatively to file being assembled (set cwd)
This commit is contained in:
@@ -146,7 +146,7 @@ impl Editor {
|
||||
}
|
||||
|
||||
if let Some(path) = FileDialog::new()
|
||||
.add_filter("damn simple files", &["dsa", "dsb", "dsc", "dsd"])
|
||||
.add_filter("Assembly Files or Binaries", &["dsa", "dsb"])
|
||||
.add_filter("all", &["*"])
|
||||
.set_directory(&work_dir)
|
||||
.save_file()
|
||||
@@ -169,17 +169,22 @@ impl Editor {
|
||||
});
|
||||
|
||||
if let Some(path) = FileDialog::new()
|
||||
.add_filter("damn simple files", &["dsa", "dsb", "dsc", "dsd"])
|
||||
.add_filter("Assembly Files or Binaries", &["dsa", "dsb"])
|
||||
.add_filter("all", &["*"])
|
||||
.set_directory(&work_dir)
|
||||
.pick_file()
|
||||
{
|
||||
if let Ok(contents) = std::fs::read_to_string(&path) {
|
||||
self.path = Some(path);
|
||||
self.path = Some(path.clone());
|
||||
self.text.clone_from(&contents);
|
||||
self.buffer = contents;
|
||||
self.unsaved = false;
|
||||
}
|
||||
|
||||
std::env::set_current_dir(
|
||||
path.parent().expect("A file should be in a directory!"),
|
||||
)
|
||||
.expect("ERROR: Failed to set current working directory.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user