Skip to content

Commit

Permalink
I need to turn fmt on save on in my editor
Browse files Browse the repository at this point in the history
  • Loading branch information
tinco committed Feb 6, 2025
1 parent 7ebdff2 commit b566d52
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
13 changes: 9 additions & 4 deletions src/agent/tools/replace_lines.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// Replace lines in a file. This tool is in beta and only has a ~80% success rate.
use swiftide::traits::CommandError;

use anyhow::Result;
Expand Down Expand Up @@ -180,18 +179,24 @@ fn replace_content(
.map(|line| {
let mut new_line = line.to_string();
if !new_line.is_empty() {
new_line.insert_str(0, &indentation_char.repeat(first_line_indentation_mismatch));
new_line
.insert_str(0, &indentation_char.repeat(first_line_indentation_mismatch));
}
new_line
})
.collect::<Vec<_>>()
.join("\n");
}

let prefix = file_content.split('\n').take(start_line - 1).collect::<Vec<_>>();
let prefix = file_content
.split('\n')
.take(start_line - 1)
.collect::<Vec<_>>();
let suffix = file_content.split('\n').skip(end_line).collect::<Vec<_>>();

let new_file_content = [prefix, content.lines().collect::<Vec<_>>(), suffix].concat().join("\n");
let new_file_content = [prefix, content.lines().collect::<Vec<_>>(), suffix]
.concat()
.join("\n");

Ok(new_file_content)
}
2 changes: 1 addition & 1 deletion src/evaluations/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl EvalOutput {
let output_dir = Path::new("evals");
let eval_dir = output_dir.join(eval_type);
let iteration_dir = eval_dir.join(format!("iteration_{iteration}"));

fs::remove_dir_all(&iteration_dir)?;
fs::create_dir_all(&iteration_dir)?;

Expand Down
6 changes: 2 additions & 4 deletions src/evaluations/patch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,8 @@ async fn run_single_evaluation(iteration: u32) -> Result<(bool, EvalMetrics)> {
let responder = Arc::new(LoggingResponder::new());

let config_path = Path::new("test-config.toml");
let repository = Repository::from_config(
Config::load(&config_path)
.expect("Failed to load config")
);
let repository =
Repository::from_config(Config::load(&config_path).expect("Failed to load config"));

let tools = get_evaluation_tools();
let agent = start_tool_evaluation_agent(&repository, responder.clone(), tools).await?;
Expand Down
2 changes: 0 additions & 2 deletions tests/test_tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,6 @@ async fn test_edit_file() {
return True
"},
);


}

#[test_log::test(tokio::test)]
Expand Down

0 comments on commit b566d52

Please sign in to comment.