Commit 3d2aa478 authored by Daniel Stone's avatar Daniel Stone Committed by Ana Rute Mendes
Browse files

LOCAL/UI: Differential: Use tab width of 8 rather than 2

It would be nice, as the comment notes, to have this customisable perhaps
per-repository, but for the meantime this is unambiguously the better
solution.
parent e330ed58
...@@ -1214,7 +1214,38 @@ final class DifferentialChangesetParser extends Phobject { ...@@ -1214,7 +1214,38 @@ final class DifferentialChangesetParser extends Phobject {
$gaps = array_reverse($gaps); $gaps = array_reverse($gaps);
$mask = $base_mask; $mask = $base_mask;
return array($gaps, $mask); // Time to calculate depth.
// We need to go backwards to properly indent whitespace in this code:
//
// 0: class C {
// 1:
// 1: function f() {
// 2:
// 2: return;
// 1:
// 1: }
// 0:
// 0: }
//
$depths = array();
$last_depth = 0;
$range_end = $range_start + $range_len;
if (!isset($this->new[$range_end])) {
$range_end--;
}
for ($ii = $range_end; $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;
}
return array($gaps, $mask, $depths);
} }
/** /**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment