(ctx: &mut ScriptContext<'_, API>)
| 1136 | .unwrap_or(false); |
| 1137 | if changed { |
| 1138 | refresh_all(ctx); |
| 1139 | } |
| 1140 | } |
| 1141 | |
| 1142 | pub fn expand_selected_file<API: ScriptAPI + ?Sized>(ctx: &mut ScriptContext<'_, API>) { |
| 1143 | let action = with_state_mut!(ctx.run, EditorState, ctx.id, |state| { |
| 1144 | if state.sidebar_mode != "files" { |
| 1145 | return None; |
| 1146 | } |
| 1147 | let active = state.active_asset_path.clone(); |
| 1148 | if active.is_empty() { |
| 1149 | return None; |
| 1150 | } |
| 1151 | if !active.ends_with('/') { |
| 1152 | return Some("open".to_string()); |
| 1153 | } |
| 1154 | if !state |
| 1155 | .file_expanded_paths |
| 1156 | .iter() |
| 1157 | .any(|expanded| expanded == &active) |
| 1158 | { |
| 1159 | reveal_file_path_in_tree(state, &active); |
| 1160 | state.log = format!("expand folder\n{}", editor_files::rel_label(&active)); |
| 1161 | return Some("refresh".to_string()); |
| 1162 | } |
| 1163 | let child = filtered_file_paths(state) |
| 1164 | .into_iter() |
| 1165 | .find(|path| parent_res_folder(path) == active); |
| 1166 | if let Some(child) = child { |
| 1167 | state.active_asset_path = child; |
| 1168 | state.log = format!( |
| 1169 | "select asset\n{}", |
| 1170 | editor_files::rel_label(&state.active_asset_path) |
| 1171 | ); |
| 1172 | return Some("refresh".to_string()); |
| 1173 | } |
| 1174 | None |
| 1175 | }) |
| 1176 | .flatten(); |
| 1177 | match action.as_deref() { |
| 1178 | Some("open") => open_active_file(ctx), |
| 1179 | Some("refresh") => refresh_all(ctx), |
| 1180 | _ => {} |
| 1181 | } |
no test coverage detected