@@ -103,32 +103,34 @@ traced_files <- function(x) {
103103 for (i in seq_along(x )) {
104104 src_file <- attr(x [[i ]]$ srcref , " srcfile" )
105105 filename <- filenames [[i ]]
106- if (is.null( res [[ filename ]])) {
107- lines <- getSrcLines( src_file , 1 , Inf )
108- matches <- rex :: re_matches( lines ,
109- rex :: rex( start , any_spaces , " #line " , spaces ,
110- capture( name = " line_number " , digit ), spaces ,
111- quotes , capture( name = " filename " , anything ), quotes ))
112-
113- matches <- na.omit( matches )
114-
115- filename_match <- which( matches $ filename == src_file $ filename )
116-
117- if (length( filename_match ) == 1 ) {
118- start <- as.numeric(rownames( matches )[ filename_match ]) + 1
119- end <- if ( ! is.na(rownames( matches )[ filename_match + 1 ])) {
120- as.numeric(rownames( matches )[ filename_match + 1 ]) - 1
121- } else {
122- length( lines )
123- }
106+
107+ if ( filename == " " ) next
108+ if ( ! is.null( res [[ filename ]])) next
109+
110+ lines <- getSrcLines( src_file , 1 , Inf )
111+ matches <- rex :: re_matches( lines ,
112+ rex :: rex( start , any_spaces , " #line " , spaces ,
113+ capture( name = " line_number " , digit ), spaces ,
114+ quotes , capture( name = " filename " , anything ), quotes ))
115+
116+ matches <- na.omit( matches )
117+
118+ filename_match <- which( matches $ filename == src_file $ filename )
119+
120+ if (length( filename_match ) == 1 ) {
121+ start <- as.numeric(rownames( matches )[ filename_match ]) + 1
122+ end <- if ( ! is.na(rownames( matches )[ filename_match + 1 ])) {
123+ as.numeric(rownames( matches )[ filename_match + 1 ]) - 1
124124 } else {
125- start <- 1
126- end <- length(lines )
125+ length(lines )
127126 }
128- src_file $ file_lines <- lines [seq( start , end )]
129-
130- res [[ filename ]] <- src_file
127+ } else {
128+ start <- 1
129+ end <- length( lines )
131130 }
131+ src_file $ file_lines <- lines [seq(start , end )]
132+
133+ res [[filename ]] <- src_file
132134 }
133135 res
134136}
0 commit comments