fixed file tree entry id, so no more conflict
This commit is contained in:
parent
7c29b40688
commit
5f3b199684
|
@ -1 +1 @@
|
||||||
{"categories":[{"name":"to do","content":[{"name":"add id to textarea per tab","description":"to improve undo, make each code area of each tab have a unique id (no more undo into another tab)","id":1},{"name":"bug project","description":"when switching tabs between two project file, if item window is open it crashes","id":1},{"name":"update workflow .yml","description":"make a workflow compiling the calcifer and put the linux in calcifer-{version}\nand the windows in calcifer_windows_{version}\n\nupdate nix\nupdate jiji","id":5},{"name":"open dir in tree ?","description":"// Hello there","id":2},{"name":"file tree id ?","description":"// Hello there","id":1}]},{"name":"in progress","content":[{"name":"export copy paste fix","description":"// Hello there","id":1}]},{"name":"done","content":[{"name":"move .project file","description":"// Hello there","id":4},{"name":"move config","description":"config from .calcifer/save.json\nto .config/calcifer/state.json","id":1}]},{"name":"+","content":[]}]}
|
{"categories":[{"name":"to do","content":[{"name":"bug project","description":"when switching tabs between two project file, if item window is open it crashes","id":1},{"name":"update workflow .yml","description":"make a workflow compiling the calcifer and put the linux in calcifer-{version}\nand the windows in calcifer_windows_{version}\n\nupdate nix\nupdate jiji","id":5},{"name":"open dir in tree ?","description":"// Hello there","id":2},{"name":"fix tab title","description":"// Hello there","id":2}]},{"name":"in progress","content":[{"name":"export copy paste fix","description":"// Hello there","id":1}]},{"name":"done","content":[{"name":"move .project file","description":"// Hello there","id":4},{"name":"move config","description":"config from .calcifer/save.json\nto .config/calcifer/state.json","id":1},{"name":"add id to textarea per tab","description":"to improve undo, make each code area of each tab have a unique id (no more undo into another tab)","id":1},{"name":"file tree id ?","description":"// Hello there","id":1}]},{"name":"+","content":[]}]}
|
|
@ -209,10 +209,13 @@ impl Calcifer {
|
||||||
|
|
||||||
if let Some(folder_content) = &file.folder_content {
|
if let Some(folder_content) = &file.folder_content {
|
||||||
let mut check_for_update: bool = false;
|
let mut check_for_update: bool = false;
|
||||||
let collapsing_response = egui::CollapsingHeader::new(file.name.clone())
|
let file_id = panels::get_file_id(&file);
|
||||||
.default_open(self.tree_dir_opened.contains(&file.name))
|
|
||||||
|
let collapsing_response = egui::CollapsingHeader::new(&file.name.clone())
|
||||||
|
.id_source(&file_id)
|
||||||
|
.default_open(self.tree_dir_opened.contains(&file_id))
|
||||||
.show(ui, |ui| {
|
.show(ui, |ui| {
|
||||||
if !self.tree_dir_opened.contains(&file.name) {
|
if !self.tree_dir_opened.contains(&file_id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for deeper_file in folder_content {
|
for deeper_file in folder_content {
|
||||||
|
@ -222,9 +225,9 @@ impl Calcifer {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if collapsing_response.fully_closed() {
|
if collapsing_response.fully_closed() {
|
||||||
self.tree_dir_opened.retain(|s| s != &file.name);
|
self.tree_dir_opened.retain(|s| s != &file_id);
|
||||||
} else if !self.tree_dir_opened.contains(&file.name) {
|
} else if !self.tree_dir_opened.contains(&file_id) {
|
||||||
self.tree_dir_opened.push(file.name.clone());
|
self.tree_dir_opened.push(file_id);
|
||||||
return !file.content_checked;
|
return !file.content_checked;
|
||||||
}
|
}
|
||||||
return check_for_update;
|
return check_for_update;
|
||||||
|
|
|
@ -35,7 +35,7 @@ impl FileEntry {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_file_tree(file: FileEntry, opened_dirs: Vec<String>) -> FileEntry {
|
pub fn update_file_tree(file: FileEntry, opened_dirs: Vec<String>) -> FileEntry {
|
||||||
if opened_dirs.contains(&file.name) {
|
if opened_dirs.contains(&get_file_id(&file)) {
|
||||||
if let Some(folder_content) = &file.folder_content {
|
if let Some(folder_content) = &file.folder_content {
|
||||||
if !file.content_checked {
|
if !file.content_checked {
|
||||||
return generate_folder_entry(&file.path);
|
return generate_folder_entry(&file.path);
|
||||||
|
@ -58,6 +58,10 @@ pub fn update_file_tree(file: FileEntry, opened_dirs: Vec<String>) -> FileEntry
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_file_id(file: &FileEntry) -> String {
|
||||||
|
format!("#{}",file.path.clone().display())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn generate_folder_entry(path: &Path) -> FileEntry {
|
pub fn generate_folder_entry(path: &Path) -> FileEntry {
|
||||||
if let Some(file_name) = path.file_name() {
|
if let Some(file_name) = path.file_name() {
|
||||||
let name = file_name.to_string_lossy().into_owned();
|
let name = file_name.to_string_lossy().into_owned();
|
||||||
|
|
Loading…
Reference in a new issue