(ctx: &mut ScriptContext<'_, API>)
| 1178 | Some("open") => open_active_file(ctx), |
| 1179 | Some("refresh") => refresh_all(ctx), |
| 1180 | _ => {} |
| 1181 | } |
| 1182 | } |
| 1183 | |
| 1184 | pub fn open_active_file<API: ScriptAPI + ?Sized>(ctx: &mut ScriptContext<'_, API>) { |
| 1185 | let idx = with_state!(ctx.run, EditorState, ctx.id, |state| { |
| 1186 | if state.sidebar_mode != "files" { |
| 1187 | return None; |
| 1188 | } |
| 1189 | let paths = filtered_file_paths(state); |
| 1190 | if paths.is_empty() { |
| 1191 | return None; |
| 1192 | } |
| 1193 | paths |
| 1194 | .iter() |
| 1195 | .position(|path| path == &state.active_asset_path) |
| 1196 | .or(Some(0)) |
| 1197 | }).unwrap_or_default(); |
| 1198 | if let Some(idx) = idx { |
| 1199 | open_file_slot(ctx, idx); |
| 1200 | } |
no test coverage detected