File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -247,39 +247,44 @@ impl Comments {
247247 let mut start_line = 0u64 ;
248248 let mut start_column = 0u64 ;
249249
250+ let mut single_line = String :: new ( ) ;
251+ let mut multi_line = String :: new ( ) ;
252+
250253 let mut current_comment = String :: new ( ) ;
251- let mut src_state_machine = src. chars ( ) . peekable ( ) ;
252- while let Some ( c) = src_state_machine. next ( ) {
253- match c {
254- '-' => {
255- if current_column < 2 {
256- current_comment. push ( c) ;
257- }
258- }
259- '/' => {
260- if current_column == 0 || current_comment. contains ( "/*" ) {
261- current_comment. push ( c) ;
254+ //let mut src_state_machine = src.chars().peekable();
255+ let mut lines = src. lines ( ) . into_iter ( ) ;
256+ for line in lines {
257+ for ( i, c) in line. chars ( ) . into_iter ( ) . enumerate ( ) {
258+ match c {
259+ '-' => {
260+ match i {
261+ 0 => {
262+ single_line. push ( c) ;
263+ start_column = i as u64 ;
264+ } ,
265+ 1 => {
266+ match single_line. is_empty ( ) {
267+ false => {
268+ if single_line. len ( ) == 1 {
269+ single_line. push ( c) ;
270+ }
271+ } ,
272+ _ => { }
273+ }
274+ }
275+ }
276+ } ,
277+ '/' => ,
278+ '*' => ,
279+ _ => {
280+ if !single_line. is_empty ( ) {
281+ single_line. push ( c) ;
282+ }
262283 }
263284 }
264- '*' => {
265- current_comment. push ( c) ;
266- }
267- '\n' => {
268- if !current_comment. is_empty ( ) {
269- current_comment. clear ( ) ;
270- }
271- current_line += 1 ;
272- current_column = 0 ;
273- }
274- _ => {
275- if current_comment. contains ( "--" ) || current_comment. contains ( "/*" ) {
276- current_comment. push ( c) ;
277- }
278- }
279- }
280- if c != '\n' {
281- current_column += 1 ;
282285 }
286+
287+ start_line += 1 ;
283288 }
284289
285290 Ok ( Self { comments } )
You can’t perform that action at this time.
0 commit comments