Truncate recent items, fix open recent project issues
This commit is contained in:
parent
8614be17f1
commit
22ec51b7e7
1 changed files with 10 additions and 1 deletions
11
src/main.rs
11
src/main.rs
|
|
@ -474,12 +474,20 @@ impl App {
|
||||||
*open = true;
|
*open = true;
|
||||||
*root = true;
|
*root = true;
|
||||||
|
|
||||||
|
for (project_name, project_path) in self.projects.iter() {
|
||||||
|
if project_path == path {
|
||||||
|
// Project already open
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Save the absolute path
|
// Save the absolute path
|
||||||
self.projects.push((name.to_string(), path.to_path_buf()));
|
self.projects.push((name.to_string(), path.to_path_buf()));
|
||||||
|
|
||||||
// Add to recent projects, ensuring only one entry
|
// Add to recent projects, ensuring only one entry
|
||||||
self.config.recent_projects.retain(|x| x != path);
|
self.config.recent_projects.retain(|x| x != path);
|
||||||
self.config.recent_projects.push_front(path.to_path_buf());
|
self.config.recent_projects.push_front(path.to_path_buf());
|
||||||
|
self.config.recent_projects.truncate(10);
|
||||||
self.save_config_no_update();
|
self.save_config_no_update();
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
|
@ -537,6 +545,7 @@ impl App {
|
||||||
// Add to recent files, ensuring only one entry
|
// Add to recent files, ensuring only one entry
|
||||||
self.config.recent_files.retain(|x| x != &canonical);
|
self.config.recent_files.retain(|x| x != &canonical);
|
||||||
self.config.recent_files.push_front(canonical.to_path_buf());
|
self.config.recent_files.push_front(canonical.to_path_buf());
|
||||||
|
self.config.recent_files.truncate(10);
|
||||||
self.save_config_no_update();
|
self.save_config_no_update();
|
||||||
|
|
||||||
let mut tab = EditorTab::new(&self.config);
|
let mut tab = EditorTab::new(&self.config);
|
||||||
|
|
@ -1623,7 +1632,7 @@ impl Application for App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Message::OpenRecentProject(index) => {
|
Message::OpenRecentProject(index) => {
|
||||||
if let Some(path) = self.config.recent_files.get(index).cloned() {
|
if let Some(path) = self.config.recent_projects.get(index).cloned() {
|
||||||
self.open_project(path);
|
self.open_project(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue