Skip to content

Commit

Permalink
test: fix test config to read from proper path
Browse files Browse the repository at this point in the history
  • Loading branch information
Beastwick18 committed May 31, 2024
1 parent 72af9d2 commit ac8d843
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,15 @@ impl App {
match C::load() {
Ok(config) => {
ctx.failed_config_load = false;
if let Err(e) = config.apply(ctx, &mut self.widgets) {
if let Err(e) = config.apply::<C>(ctx, &mut self.widgets) {
ctx.show_error(e);
} else if let Err(e) = ctx.save_config() {
ctx.show_error(e);
}
}
Err(e) => {
ctx.show_error(format!("Failed to load config:\n{}", e));
if let Err(e) = ctx.config.clone().apply(ctx, &mut self.widgets) {
if let Err(e) = ctx.config.clone().apply::<C>(ctx, &mut self.widgets) {
ctx.show_error(e);
}
}
Expand Down
8 changes: 6 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ impl ConfigManager for Config {
}

impl Config {
pub fn apply(&self, ctx: &mut Context, w: &mut Widgets) -> Result<(), Box<dyn Error>> {
pub fn apply<C: ConfigManager>(
&self,
ctx: &mut Context,
w: &mut Widgets,
) -> Result<(), Box<dyn Error>> {
ctx.config = self.clone();
w.search.input.cursor = w.search.input.input.len();
w.sort.selected.sort = 0;
Expand All @@ -99,7 +103,7 @@ impl Config {
}

ctx.client.load_config(ctx);
let path = Self::path().map_err(|e| e.to_string())?;
let path = C::path().map_err(|e| e.to_string())?;
theme::load_user_themes(ctx, path)?;

// Load defaults for default source
Expand Down

0 comments on commit ac8d843

Please sign in to comment.