Multi-line highlighting in Diffusion.
Summary: Currently, Diffusion supports highlighting of line ranges passed in the URI. It would be helpful to be able to highlight multiple line ranges. Test Plan: Accessed directly via URL in my sandbox. Seems to work. I'm not sure what other components use this functionality, but this change should be backwards compatible. Reviewers: epriestley Reviewed By: epriestley CC: aran, epriestley, Korvin Differential Revision: https://secure.phabricator.com/D2921
This commit is contained in:
@@ -293,15 +293,22 @@ final class DiffusionBrowseFileController extends DiffusionController {
|
||||
$epoch_range = ($epoch_max - $epoch_min) + 1;
|
||||
}
|
||||
|
||||
$min_line = 0;
|
||||
$line = $drequest->getLine();
|
||||
if (strpos($line, '-') !== false) {
|
||||
list($min, $max) = explode('-', $line, 2);
|
||||
$min_line = min($min, $max);
|
||||
$max_line = max($min, $max);
|
||||
} else if (strlen($line)) {
|
||||
$min_line = $line;
|
||||
$max_line = $line;
|
||||
$line_arr = array();
|
||||
$line_str = $drequest->getLine();
|
||||
$ranges = explode(',', $line_str);
|
||||
foreach ($ranges as $range) {
|
||||
if (strpos($range, '-') !== false) {
|
||||
list($min, $max) = explode('-', $range, 2);
|
||||
$line_arr[] = array(
|
||||
'min' => min($min, $max),
|
||||
'max' => max($min, $max),
|
||||
);
|
||||
} else if (strlen($range)) {
|
||||
$line_arr[] = array(
|
||||
'min' => $range,
|
||||
'max' => $range,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$display = array();
|
||||
@@ -366,12 +373,15 @@ final class DiffusionBrowseFileController extends DiffusionController {
|
||||
}
|
||||
}
|
||||
|
||||
if ($min_line) {
|
||||
if ($line_number == $min_line) {
|
||||
if ($line_arr) {
|
||||
if ($line_number == $line_arr[0]['min']) {
|
||||
$display_line['target'] = true;
|
||||
}
|
||||
if ($line_number >= $min_line && $line_number <= $max_line) {
|
||||
$display_line['highlighted'] = true;
|
||||
foreach ($line_arr as $range) {
|
||||
if ($line_number >= $range['min'] &&
|
||||
$line_number <= $range['max']) {
|
||||
$display_line['highlighted'] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user