@@ -148,7 +148,7 @@ pub fn scan_string(str: String, filename: PathBuf, entries: &mut Vec<Entry>) {
148
148
continue ;
149
149
}
150
150
151
- for word in line. split_whitespace ( ) {
151
+ for mut word in line. split_whitespace ( ) {
152
152
if ! word. to_lowercase ( ) . starts_with ( "todo" ) {
153
153
continue ;
154
154
}
@@ -168,9 +168,11 @@ pub fn scan_string(str: String, filename: PathBuf, entries: &mut Vec<Entry>) {
168
168
break ;
169
169
}
170
170
171
+ word = word. trim_end_matches ( ':' ) ;
172
+
171
173
// Handles: `todo`, `TODO`, `todo:`, `TODO:`
172
174
// Also trims `"` and `'` to handle cases like `foo="bar todo"`
173
- if word. to_lowercase ( ) . trim_end_matches ( ':' ) . trim_end_matches ( ' "') . trim_end_matches ( '\'' ) == "todo" {
175
+ if word. to_lowercase ( ) . trim_end_matches ( '"' ) . trim_end_matches ( '\'' ) == "todo" {
174
176
entries. push ( Entry {
175
177
text : text. to_string ( ) ,
176
178
location : Location {
@@ -289,8 +291,8 @@ pub fn scan_todo_file(path: &Path, entries: &mut Vec<Entry>) -> io::Result<()> {
289
291
}
290
292
291
293
for word in line. split_whitespace ( ) {
292
- if word. to_lowercase ( ) . starts_with ( "todo" ) && word. chars ( ) . any ( |ch| PRIORITY_CHARS . contains ( & ch) ) {
293
- if let Some ( priority) = parse_priority ( word) {
294
+ if word. to_lowercase ( ) . trim_end_matches ( ':' ) . starts_with ( "todo" ) && word. chars ( ) . any ( |ch| PRIORITY_CHARS . contains ( & ch) ) {
295
+ if let Some ( priority) = parse_priority ( word. trim_end_matches ( ':' ) ) {
294
296
entries. push ( Entry {
295
297
text : clean_line ( line, word) . to_string ( ) ,
296
298
location : Location {
@@ -360,8 +362,8 @@ pub fn scan_readme_file(path: &Path, entries: &mut Vec<Entry>) -> io::Result<()>
360
362
}
361
363
362
364
for word in line. split_whitespace ( ) {
363
- if word. to_lowercase ( ) . starts_with ( "todo" ) && word. chars ( ) . any ( |ch| PRIORITY_CHARS . contains ( & ch) ) {
364
- if let Some ( priority) = parse_priority ( word) {
365
+ if word. to_lowercase ( ) . trim_end_matches ( ':' ) . starts_with ( "todo" ) && word. chars ( ) . any ( |ch| PRIORITY_CHARS . contains ( & ch) ) {
366
+ if let Some ( priority) = parse_priority ( word. trim_end_matches ( ':' ) ) {
365
367
entries. push ( Entry {
366
368
text : clean_line ( line, word) . to_string ( ) ,
367
369
location : Location {
@@ -926,7 +928,7 @@ mod tests {
926
928
927
929
scan_readme_file ( path. as_path ( ) , & mut entries) . unwrap ( ) ;
928
930
929
- assert_eq ! ( 4 , entries. len( ) ) ;
931
+ assert_eq ! ( 5 , entries. len( ) ) ;
930
932
931
933
assert_eq ! ( Entry {
932
934
data: EntryData :: Generic ,
@@ -947,8 +949,8 @@ mod tests {
947
949
} , entries[ 1 ] ) ;
948
950
949
951
assert_eq ! ( Entry {
950
- data: EntryData :: Generic ,
951
- text: String :: from( "bar " ) ,
952
+ data: EntryData :: Priority ( - 1 ) ,
953
+ text: String :: from( "ghi " ) ,
952
954
location: Location {
953
955
file: path. clone( ) ,
954
956
line: 21 ,
@@ -957,11 +959,20 @@ mod tests {
957
959
958
960
assert_eq ! ( Entry {
959
961
data: EntryData :: Generic ,
960
- text: String :: from( "baz " ) ,
962
+ text: String :: from( "bar " ) ,
961
963
location: Location {
962
964
file: path. clone( ) ,
963
965
line: 22 ,
964
966
}
965
967
} , entries[ 3 ] ) ;
968
+
969
+ assert_eq ! ( Entry {
970
+ data: EntryData :: Generic ,
971
+ text: String :: from( "baz" ) ,
972
+ location: Location {
973
+ file: path. clone( ) ,
974
+ line: 23 ,
975
+ }
976
+ } , entries[ 4 ] ) ;
966
977
}
967
978
}
0 commit comments