Skip to content

Commit

Permalink
fix(add_last_case): set it append.
Browse files Browse the repository at this point in the history
ui(add_last_case): add info.
  • Loading branch information
saying121 committed Jun 6, 2024
1 parent 80c313e commit 5d3c289
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion crates/lcode/src/mytui/ui/edit_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ pub fn draw_pop_submit(f: &mut Frame, app: &mut App, area: Rect) {

let mut title = vec!["Submit 🌊".set_style(G_THEME.edit.submit_title)];
if app.edit.submit.need_add() {
title.push("Can add last test case 🧪".red());
title.push("Can add last test case, default press `a` 🧪".red());
}
let block = title_block(Line::from(title));
f.render_widget(block, area);
Expand Down
10 changes: 9 additions & 1 deletion crates/leetcode-api/src/dao/save_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,22 @@ impl FileInfo {
.await
.into_diagnostic()
}
async fn append_file(path: impl AsRef<Path>) -> Result<File> {
OpenOptions::new()
.create(true)
.append(true)
.open(path)
.await
.into_diagnostic()
}

/// When submit have testcase failed, can call it.
pub async fn append_test_case(&self, case: &str) -> Result<()> {
if case.is_empty() {
return Ok(());
}

let mut f = Self::rest_file(&self.test_case_path).await?;
let mut f = Self::append_file(&self.test_case_path).await?;

f.write_all(b"\n")
.await
Expand Down

0 comments on commit 5d3c289

Please sign in to comment.