mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-13 02:12:41 +01:00
Display context in changeset gaps
Summary: I quite often wonder what's inside these gaps displayed in changeset. In which method I am? Is it a while loop or a foreach? Maybe I'm in a class but the project doesn't have a sctrict policy of one class per file so what's the name of the class? I've experimented with bunch of rules: - Always display 0 indentation: useless for one class per file. - Always display 1 indentation: weird inside global functions. - Display closest lower indentation: works best. I'm not sure about highlighting the context. I like highlighting but maybe in this case subtler monochrome text will work better. Test Plan: Browsed bunch of diffs, loved it. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D3371
This commit is contained in:
parent
40cccb0077
commit
ca1775b468
1 changed files with 38 additions and 5 deletions
|
@ -1363,6 +1363,28 @@ final class DifferentialChangesetParser {
|
||||||
$highlight_new = array_flip($highlight_new);
|
$highlight_new = array_flip($highlight_new);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We need to go backwards to properly indent whitespace in this code:
|
||||||
|
//
|
||||||
|
// 0: class C {
|
||||||
|
// 1:
|
||||||
|
// 1: function f() {
|
||||||
|
// 2:
|
||||||
|
// 2: return;
|
||||||
|
//
|
||||||
|
$depths = array();
|
||||||
|
$last_depth = 0;
|
||||||
|
for ($ii = $range_start + $range_len - 1; $ii >= $range_start; $ii--) {
|
||||||
|
// We need to expand tabs to process mixed indenting and to round
|
||||||
|
// correctly later.
|
||||||
|
$line = str_replace("\t", " ", $this->new[$ii]['text']);
|
||||||
|
$trimmed = ltrim($line);
|
||||||
|
if ($trimmed != '') {
|
||||||
|
// We round down to flatten "/**" and " *".
|
||||||
|
$last_depth = floor((strlen($line) - strlen($trimmed)) / 2);
|
||||||
|
}
|
||||||
|
$depths[$ii] = $last_depth;
|
||||||
|
}
|
||||||
|
|
||||||
for ($ii = $range_start; $ii < $range_start + $range_len; $ii++) {
|
for ($ii = $range_start; $ii < $range_start + $range_len; $ii++) {
|
||||||
if (empty($mask[$ii])) {
|
if (empty($mask[$ii])) {
|
||||||
// If we aren't going to show this line, we've just entered a gap.
|
// If we aren't going to show this line, we've just entered a gap.
|
||||||
|
@ -1414,12 +1436,12 @@ final class DifferentialChangesetParser {
|
||||||
),
|
),
|
||||||
'Show All '.$len.' Lines');
|
'Show All '.$len.' Lines');
|
||||||
|
|
||||||
if ($len > 40) {
|
$is_last_block = false;
|
||||||
$is_last_block = false;
|
if ($ii + $len >= $rows) {
|
||||||
if ($ii + $len >= $rows) {
|
$is_last_block = true;
|
||||||
$is_last_block = true;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
if ($len > 40) {
|
||||||
$contents[] = javelin_render_tag(
|
$contents[] = javelin_render_tag(
|
||||||
'a',
|
'a',
|
||||||
array(
|
array(
|
||||||
|
@ -1436,6 +1458,17 @@ final class DifferentialChangesetParser {
|
||||||
: "\xE2\x96\xBC Show 20 Lines");
|
: "\xE2\x96\xBC Show 20 Lines");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$is_last_block && $depths[$ii + $len]) {
|
||||||
|
for ($l = $ii + $len - 1; $l >= $ii; $l--) {
|
||||||
|
$line = $this->new[$l]['text'];
|
||||||
|
if ($depths[$l] < $depths[$ii + $len] && trim($line) != '') {
|
||||||
|
$contents[] = '<code>'.$this->newRender[$l].'</code>';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
$container = javelin_render_tag(
|
$container = javelin_render_tag(
|
||||||
'tr',
|
'tr',
|
||||||
array(
|
array(
|
||||||
|
|
Loading…
Reference in a new issue