Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexKnauth committed Dec 12, 2023
1 parent dbe5228 commit bce9e8f
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{
collections::BTreeMap,
fs::{self, File},
io::Write,
path::{PathBuf, Path},
path::{Path, PathBuf},
sync::{
atomic::{AtomicU64, AtomicUsize},
Arc, Mutex, RwLock, RwLockWriteGuard,
Expand All @@ -27,8 +27,8 @@ use egui_file::FileDialog;
use egui_plot::{Bar, BarChart, Legend, Plot, VLine};
use hdrhistogram::Histogram;
use indexmap::IndexMap;
use livesplit_auto_splitting::wasi_path::{path_to_wasi, wasi_to_path};
use livesplit_auto_splitting::{settings, time, Config, Runtime, Timer, TimerState};
use livesplit_auto_splitting::wasi_path::{wasi_to_path, path_to_wasi};

mod clear_vec;

Expand Down Expand Up @@ -611,19 +611,25 @@ impl egui_dock::TabViewer for TabViewer<'_> {
settings::WidgetKind::FileSelection { ref filter } => {
ui.add_space(spacing);
let settings_map = runtime.settings_map();
let current_path: Option<PathBuf> = match settings_map.get(&setting.key) {
Some(settings::Value::String(path)) => wasi_to_path(path),
_ => None,
};
let filter_pieces: Vec<String> = filter.split('*').map(String::from).collect();
let current_path: Option<PathBuf> =
match settings_map.get(&setting.key) {
Some(settings::Value::String(path)) => wasi_to_path(path),
_ => None,
};
let filter_pieces: Vec<String> =
filter.split('*').map(String::from).collect();
if ui.button(&*setting.description).clicked() {
let mut dialog = FileDialog::open_file(current_path)
.filter(Box::new(move |p: &Path| {
let mut dialog = FileDialog::open_file(current_path).filter(
Box::new(move |p: &Path| {
let s = p.to_string_lossy();
filter_pieces.iter().all(|f| s.contains(f))
}));
}),
);
dialog.open();
self.state.open_file_dialog = Some((dialog, FileDialogInfo::SettingsWidget(setting.key.clone())));
self.state.open_file_dialog = Some((
dialog,
FileDialogInfo::SettingsWidget(setting.key.clone()),
));
}
}
});
Expand Down Expand Up @@ -824,7 +830,9 @@ impl App for Debugger {
FileDialogInfo::Script => self.state.set_script_path(file),
FileDialogInfo::SettingsWidget(key) => {
if let Some(s) = path_to_wasi(&file) {
if let Some(runtime) = &*self.state.shared_state.runtime.read().unwrap() {
if let Some(runtime) =
&*self.state.shared_state.runtime.read().unwrap()
{
loop {
let old = runtime.settings_map();
let mut new = old.clone();
Expand Down

0 comments on commit bce9e8f

Please sign in to comment.