@@ -1422,7 +1422,9 @@ impl<'a> Iterator for LineClasses<'a> {
14221422 None => unreachable ! ( ) ,
14231423 } ;
14241424
1425+ let mut prev_kind = FullCodeCharKind :: Normal ;
14251426 while let Some ( ( kind, c) ) = self . base . next ( ) {
1427+ prev_kind = self . kind ;
14261428 // needed to set the kind of the ending character on the last line
14271429 self . kind = kind;
14281430 if c == '\n' {
@@ -1439,6 +1441,9 @@ impl<'a> Iterator for LineClasses<'a> {
14391441 ( FullCodeCharKind :: InStringCommented , FullCodeCharKind :: InComment ) => {
14401442 FullCodeCharKind :: EndStringCommented
14411443 }
1444+ ( _, FullCodeCharKind :: Normal ) if prev_kind == FullCodeCharKind :: EndComment => {
1445+ FullCodeCharKind :: EndComment
1446+ }
14421447 _ => kind,
14431448 } ;
14441449 break ;
@@ -1993,12 +1998,28 @@ fn main() {
19931998}
19941999"# ;
19952000 assert_eq ! ( s, filter_normal_code( s) ) ;
1996- let s_with_comment = r#"
2001+ let s_with_line_comment = r#"
19972002fn main() {
19982003 // hello, world
19992004 println!("hello, world");
20002005}
20012006"# ;
2002- assert_eq ! ( s, filter_normal_code( s_with_comment) ) ;
2007+ assert_eq ! ( s, filter_normal_code( s_with_line_comment) ) ;
2008+ let s_with_block_comment = r#"
2009+ fn main() {
2010+ /* hello, world */
2011+ println!("hello, world");
2012+ }
2013+ "# ;
2014+ assert_eq ! ( s, filter_normal_code( s_with_block_comment) ) ;
2015+ let s_with_multi_line_comment = r#"
2016+ fn main() {
2017+ /* hello,
2018+ * world
2019+ */
2020+ println!("hello, world");
2021+ }
2022+ "# ;
2023+ assert_eq ! ( s, filter_normal_code( s_with_multi_line_comment) ) ;
20032024 }
20042025}
0 commit comments