Closed GaryJones closed 11 years ago
The problem seems to be related to the way the range()
array is added to the existing $highlight
array, with values under duplicate keys being dropped. Suspect an array_push()
is needed here.
Consider this issue solved - will close when committed.
public function parse_highlight_arg( $line_numbers ) {
if ( empty( $line_numbers ) ) {
return null;
}
// Determine which lines should be highlighted.
$highlight = array_map('trim', explode( ',', $line_numbers ));
// Convert any ranges.
foreach ( $highlight as $key => $num ) {
if ( false !== strpos( $num, '-' ) ) {
unset( $highlight[ $key ] );
$range = array_map( 'trim', explode( '-', $num ) );
foreach ( range( $range[0], $range[1] ) as $line )
array_push($highlight, $line);
}
}
return array_unique( $highlight );
}
See http://d.pr/i/caiS - not sure that the line highlighting logic is quite right for ranges, since lines 9 and 11 should also be highlighted in the screenshot.
Debug comes out as:
(Using my rewritten dev branch, which adds a couple of
trim()
s in, so might be something I've screwed up.)