Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3c5dcff

Browse files
committed
format file name
1 parent 541a06d commit 3c5dcff

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

‎src/config/code.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,16 @@ impl Default for Code {
4747
editor: "vim".into(),
4848
editor_args: None,
4949
editor_envs: None,
50-
edit_code_marker: false,
51-
start_marker: "".into(),
52-
end_marker: "".into(),
53-
inject_before: None,
54-
inject_after: None,
55-
comment_problem_desc: false,
56-
comment_leading: "".into(),
50+
edit_code_marker: true,
51+
start_marker: "leetcode_submit_start_marker".into(),
52+
end_marker: "leetcode_submit_end_marker".into(),
53+
inject_before: Some(vec!["struct Solution {}\n".to_string()]),
54+
inject_after: Some(vec!["\n#[cfg(test)]\nmod tests {\n use super::*;\n #[test]\n fn it_works() {\n\n }\n}".to_string()]),
55+
comment_problem_desc: true,
56+
comment_leading: "//".into(),
5757
test: true,
5858
lang: "rust".into(),
59-
pick: "${fid}.${slug}".into(),
59+
pick: "${fid}_${slug}".into(),
6060
submission: "${fid}.${slug}.${sid}.${ac}".into(),
6161
}
6262
}

‎src/helper.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,9 @@ mod file {
198198
let conf = crate::config::Config::locate()?;
199199
let mut path = format!("{}/{}.tests.dat", conf.storage.code()?, conf.code.pick);
200200

201-
path = path.replace("${fid}", &problem.fid.to_string());
202-
path = path.replace("${slug}", &problem.slug.to_string());
201+
path = path.replace("${fid}", &format!("p{:04}", problem.fid));
202+
path = path.replace("${slug}", &problem.slug.to_string().replace("-", "_"));
203+
203204
Ok(path)
204205
}
205206

@@ -218,8 +219,8 @@ mod file {
218219
suffix(&lang)?,
219220
);
220221

221-
path = path.replace("${fid}", &problem.fid.to_string());
222-
path = path.replace("${slug}", &problem.slug.to_string());
222+
path = path.replace("${fid}", &format!("p{:04}",problem.fid));
223+
path = path.replace("${slug}", &problem.slug.to_string().replace("-","_"));
223224

224225
Ok(path)
225226
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /