mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-27 09:12:41 +01:00
Multiline Highlighting in Diffusion
Summary: I added multiline highlighting with the syntax: http://site/path/to/file$from-to NOTE: you can reverse the from and to Test Plan: Open a file in diffusion and attempt to highlight multiple lines Reviewers: epriestley CC: aran, epriestley Differential Revision: https://secure.phabricator.com/D1693
This commit is contained in:
parent
ecc81ca9dc
commit
e24a6acf58
2 changed files with 20 additions and 5 deletions
|
@ -265,7 +265,7 @@ class AphrontDefaultApplicationConfiguration
|
||||||
'browse/'.
|
'browse/'.
|
||||||
'(?P<path>.*?)'.
|
'(?P<path>.*?)'.
|
||||||
'(?:[;](?P<commit>[a-z0-9]+))?'.
|
'(?:[;](?P<commit>[a-z0-9]+))?'.
|
||||||
'(?:[$](?P<line>\d+))?'.
|
'(?:[$](?P<line>\d+(?:-\d+)?))?'.
|
||||||
'$'
|
'$'
|
||||||
=> 'DiffusionBrowseController',
|
=> 'DiffusionBrowseController',
|
||||||
'diff/'.
|
'diff/'.
|
||||||
|
|
|
@ -313,6 +313,19 @@ class DiffusionBrowseFileController extends DiffusionController {
|
||||||
$range = 1;
|
$range = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$targ = '';
|
||||||
|
$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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
foreach ($text_list as $k => $line) {
|
foreach ($text_list as $k => $line) {
|
||||||
if ($needs_blame) {
|
if ($needs_blame) {
|
||||||
// If the line's rev is same as the line above, show empty content
|
// If the line's rev is same as the line above, show empty content
|
||||||
|
@ -370,11 +383,13 @@ class DiffusionBrowseFileController extends DiffusionController {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Highlight the line of interest if needed.
|
// Highlight the line of interest if needed.
|
||||||
if ($n == $drequest->getLine()) {
|
if ($min_line > 0 && ($n >= $min_line && $n <= $max_line)) {
|
||||||
$tr = '<tr style="background: #ffff00;">';
|
$tr = '<tr style="background: #ffff00;">';
|
||||||
$targ = '<a id="scroll_target"></a>';
|
if ($targ == '') {
|
||||||
Javelin::initBehavior('diffusion-jump-to',
|
$targ = '<a id="scroll_target"></a>';
|
||||||
array('target' => 'scroll_target'));
|
Javelin::initBehavior('diffusion-jump-to',
|
||||||
|
array('target' => 'scroll_target'));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$tr = '<tr>';
|
$tr = '<tr>';
|
||||||
$targ = null;
|
$targ = null;
|
||||||
|
|
Loading…
Reference in a new issue