Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15427428
D20198.id48225.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D20198.id48225.diff
View Options
diff --git a/src/applications/differential/render/DifferentialChangesetRenderer.php b/src/applications/differential/render/DifferentialChangesetRenderer.php
--- a/src/applications/differential/render/DifferentialChangesetRenderer.php
+++ b/src/applications/differential/render/DifferentialChangesetRenderer.php
@@ -33,7 +33,7 @@
private $canMarkDone;
private $objectOwnerPHID;
private $highlightingDisabled;
- private $scopeEngine;
+ private $scopeEngine = false;
private $depthOnlyLines;
private $oldFile = false;
@@ -677,13 +677,23 @@
return $views;
}
-
final protected function getScopeEngine() {
- if (!$this->scopeEngine) {
- $line_map = $this->getNewLineTextMap();
+ if ($this->scopeEngine === false) {
+ $hunk_starts = $this->getHunkStartLines();
+
+ // If this change is missing context, don't try to identify scopes, since
+ // we won't really be able to get anywhere.
+ $has_multiple_hunks = (count($hunk_starts) > 1);
+ $has_offset_hunks = (head_key($hunk_starts) != 1);
+ $missing_context = ($has_multiple_hunks || $has_offset_hunks);
- $scope_engine = id(new PhabricatorDiffScopeEngine())
- ->setLineTextMap($line_map);
+ if ($missing_context) {
+ $scope_engine = null;
+ } else {
+ $line_map = $this->getNewLineTextMap();
+ $scope_engine = id(new PhabricatorDiffScopeEngine())
+ ->setLineTextMap($line_map);
+ }
$this->scopeEngine = $scope_engine;
}
diff --git a/src/applications/differential/render/DifferentialChangesetTwoUpRenderer.php b/src/applications/differential/render/DifferentialChangesetTwoUpRenderer.php
--- a/src/applications/differential/render/DifferentialChangesetTwoUpRenderer.php
+++ b/src/applications/differential/render/DifferentialChangesetTwoUpRenderer.php
@@ -94,7 +94,7 @@
$context_text = null;
$context_line = null;
- if (!$is_last_block) {
+ if (!$is_last_block && $scope_engine) {
$target_line = $new_lines[$ii + $len]['line'];
$context_line = $scope_engine->getScopeStart($target_line);
if ($context_line !== null) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Mar 24, 2:29 PM (4 d, 6 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7660745
Default Alt Text
D20198.id48225.diff (2 KB)
Attached To
Mode
D20198: Don't enable the "ScopeEngine" or try to identify scope context for diffs without context
Attached
Detach File
Event Timeline
Log In to Comment