mirror of
https://github.com/archtechx/todo-system.git
synced 2025-12-12 00:54:03 +00:00
Ignore colons (fix #2)
This commit is contained in:
parent
9fe36adf20
commit
e83185a687
4 changed files with 26 additions and 14 deletions
|
|
@ -2,7 +2,7 @@ function add(foo: any, bar: any): any { // todo@types
|
|||
return foo + bar;
|
||||
}
|
||||
|
||||
function subtract(foo: any, bar: any): any { // todo@types add types
|
||||
function subtract(foo: any, bar: any): any { // todo@types: add types
|
||||
return foo - bar;
|
||||
}
|
||||
|
||||
|
|
@ -24,12 +24,12 @@ function greet2(name: string) { // todo1 add return typehint
|
|||
console.log(`Hello ${name}`);
|
||||
}
|
||||
|
||||
function echo(str: string) { // todo2 add return typehint
|
||||
function echo(str: string) { // todo2: add return typehint
|
||||
console.log(str);
|
||||
}
|
||||
|
||||
// console.log('foo'); // todo
|
||||
|
||||
// todo generic todo 2
|
||||
// todo: generic todo 2
|
||||
// TODO: generic todo 3
|
||||
// todo11 invalid todo
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ def
|
|||
|
||||
- abc
|
||||
- todo0 def
|
||||
- todo00: ghi
|
||||
- [ ] bar
|
||||
- [ ] baz
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
- todo00 priority bar
|
||||
|
||||
## High priority
|
||||
- todo0 a
|
||||
- todo0: a
|
||||
- foo
|
||||
- [ ] bar
|
||||
|
||||
|
|
|
|||
31
src/scan.rs
31
src/scan.rs
|
|
@ -148,7 +148,7 @@ pub fn scan_string(str: String, filename: PathBuf, entries: &mut Vec<Entry>) {
|
|||
continue;
|
||||
}
|
||||
|
||||
for word in line.split_whitespace() {
|
||||
for mut word in line.split_whitespace() {
|
||||
if ! word.to_lowercase().starts_with("todo") {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -168,9 +168,11 @@ pub fn scan_string(str: String, filename: PathBuf, entries: &mut Vec<Entry>) {
|
|||
break;
|
||||
}
|
||||
|
||||
word = word.trim_end_matches(':');
|
||||
|
||||
// Handles: `todo`, `TODO`, `todo:`, `TODO:`
|
||||
// Also trims `"` and `'` to handle cases like `foo="bar todo"`
|
||||
if word.to_lowercase().trim_end_matches(':').trim_end_matches('"').trim_end_matches('\'') == "todo" {
|
||||
if word.to_lowercase().trim_end_matches('"').trim_end_matches('\'') == "todo" {
|
||||
entries.push(Entry {
|
||||
text: text.to_string(),
|
||||
location: Location {
|
||||
|
|
@ -289,8 +291,8 @@ pub fn scan_todo_file(path: &Path, entries: &mut Vec<Entry>) -> io::Result<()> {
|
|||
}
|
||||
|
||||
for word in line.split_whitespace() {
|
||||
if word.to_lowercase().starts_with("todo") && word.chars().any(|ch| PRIORITY_CHARS.contains(&ch)) {
|
||||
if let Some(priority) = parse_priority(word) {
|
||||
if word.to_lowercase().trim_end_matches(':').starts_with("todo") && word.chars().any(|ch| PRIORITY_CHARS.contains(&ch)) {
|
||||
if let Some(priority) = parse_priority(word.trim_end_matches(':')) {
|
||||
entries.push(Entry {
|
||||
text: clean_line(line, word).to_string(),
|
||||
location: Location {
|
||||
|
|
@ -360,8 +362,8 @@ pub fn scan_readme_file(path: &Path, entries: &mut Vec<Entry>) -> io::Result<()>
|
|||
}
|
||||
|
||||
for word in line.split_whitespace() {
|
||||
if word.to_lowercase().starts_with("todo") && word.chars().any(|ch| PRIORITY_CHARS.contains(&ch)) {
|
||||
if let Some(priority) = parse_priority(word) {
|
||||
if word.to_lowercase().trim_end_matches(':').starts_with("todo") && word.chars().any(|ch| PRIORITY_CHARS.contains(&ch)) {
|
||||
if let Some(priority) = parse_priority(word.trim_end_matches(':')) {
|
||||
entries.push(Entry {
|
||||
text: clean_line(line, word).to_string(),
|
||||
location: Location {
|
||||
|
|
@ -926,7 +928,7 @@ mod tests {
|
|||
|
||||
scan_readme_file(path.as_path(), &mut entries).unwrap();
|
||||
|
||||
assert_eq!(4, entries.len());
|
||||
assert_eq!(5, entries.len());
|
||||
|
||||
assert_eq!(Entry {
|
||||
data: EntryData::Generic,
|
||||
|
|
@ -947,8 +949,8 @@ mod tests {
|
|||
}, entries[1]);
|
||||
|
||||
assert_eq!(Entry {
|
||||
data: EntryData::Generic,
|
||||
text: String::from("bar"),
|
||||
data: EntryData::Priority(-1),
|
||||
text: String::from("ghi"),
|
||||
location: Location {
|
||||
file: path.clone(),
|
||||
line: 21,
|
||||
|
|
@ -957,11 +959,20 @@ mod tests {
|
|||
|
||||
assert_eq!(Entry {
|
||||
data: EntryData::Generic,
|
||||
text: String::from("baz"),
|
||||
text: String::from("bar"),
|
||||
location: Location {
|
||||
file: path.clone(),
|
||||
line: 22,
|
||||
}
|
||||
}, entries[3]);
|
||||
|
||||
assert_eq!(Entry {
|
||||
data: EntryData::Generic,
|
||||
text: String::from("baz"),
|
||||
location: Location {
|
||||
file: path.clone(),
|
||||
line: 23,
|
||||
}
|
||||
}, entries[4]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue