@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix DocumentEngine line behaviors in Diffusion

Summary:
Ref T13105. Fixes some issues with line linking and highlighting under DocumentEngine:

- Adding `$1-3` to the URI didn't work correctly with query parameters.
- Reading `$1-3` from the URI didn't work correctly because Diffusion parses them slightly abnormally.

Test Plan: Clicked/dragged lines to select them. Observed URI. Reloaded page, got the right selection.

Reviewers: mydeveloperday

Reviewed By: mydeveloperday

Maniphest Tasks: T13105

Differential Revision: https://secure.phabricator.com/D19305

+49 -27
+8 -8
resources/celerity/map.php
··· 473 473 'rsrc/js/core/behavior-keyboard-pager.js' => 'a8da01f0', 474 474 'rsrc/js/core/behavior-keyboard-shortcuts.js' => '01fca1f0', 475 475 'rsrc/js/core/behavior-lightbox-attachments.js' => '6b31879a', 476 - 'rsrc/js/core/behavior-line-linker.js' => '13e39479', 476 + 'rsrc/js/core/behavior-line-linker.js' => 'febf4ae7', 477 477 'rsrc/js/core/behavior-more.js' => 'a80d0378', 478 478 'rsrc/js/core/behavior-object-selector.js' => '77c1f0b0', 479 479 'rsrc/js/core/behavior-oncopy.js' => '2926fff2', ··· 638 638 'javelin-behavior-phabricator-gesture-example' => '558829c2', 639 639 'javelin-behavior-phabricator-keyboard-pager' => 'a8da01f0', 640 640 'javelin-behavior-phabricator-keyboard-shortcuts' => '01fca1f0', 641 - 'javelin-behavior-phabricator-line-linker' => '13e39479', 641 + 'javelin-behavior-phabricator-line-linker' => 'febf4ae7', 642 642 'javelin-behavior-phabricator-nav' => '836f966d', 643 643 'javelin-behavior-phabricator-notification-example' => '8ce821c5', 644 644 'javelin-behavior-phabricator-object-selector' => '77c1f0b0', ··· 963 963 '0f764c35' => array( 964 964 'javelin-install', 965 965 'javelin-util', 966 - ), 967 - '13e39479' => array( 968 - 'javelin-behavior', 969 - 'javelin-stratcom', 970 - 'javelin-dom', 971 - 'javelin-history', 972 966 ), 973 967 '15d5ff71' => array( 974 968 'aphront-typeahead-control-css', ··· 2173 2167 'javelin-dom', 2174 2168 'javelin-view-visitor', 2175 2169 'javelin-util', 2170 + ), 2171 + 'febf4ae7' => array( 2172 + 'javelin-behavior', 2173 + 'javelin-stratcom', 2174 + 'javelin-dom', 2175 + 'javelin-history', 2176 2176 ), 2177 2177 ), 2178 2178 'packages' => array(
+4
src/aphront/AphrontRequest.php
··· 61 61 */ 62 62 public function getURILineRange($key, $limit) { 63 63 $range = $this->getURIData($key); 64 + return self::parseURILineRange($range, $limit); 65 + } 66 + 67 + public static function parseURILineRange($range, $limit) { 64 68 if (!strlen($range)) { 65 69 return null; 66 70 }
+9 -4
src/applications/diffusion/document/DiffusionDocumentRenderingEngine.php
··· 14 14 return $this->diffusionRequest; 15 15 } 16 16 17 - protected function getSelectedDocumentEngineKey() { 18 - return $this->getRequest()->getStr('as'); 19 - } 20 - 21 17 protected function newRefViewURI( 22 18 PhabricatorDocumentRef $ref, 23 19 PhabricatorDocumentEngine $engine) { ··· 56 52 'filePHID' => $file_phid, 57 53 ), 58 54 )); 55 + } 56 + 57 + protected function getSelectedDocumentEngineKey() { 58 + return $this->getRequest()->getStr('as'); 59 + } 60 + 61 + protected function getSelectedLineRange() { 62 + $range = $this->getDiffusionRequest()->getLine(); 63 + return AphrontRequest::parseURILineRange($range, 1000); 59 64 } 60 65 61 66 protected function addApplicationCrumbs(
+17 -13
src/applications/files/document/render/PhabricatorDocumentRenderingEngine.php
··· 54 54 } 55 55 $engine = $engines[$engine_key]; 56 56 57 - $lines = $request->getURILineRange('lines', 1000); 57 + $lines = $this->getSelectedLineRange(); 58 58 if ($lines) { 59 59 $engine->setHighlightedLines(range($lines[0], $lines[1])); 60 60 } ··· 157 157 ->appendChild($viewport); 158 158 } 159 159 160 - abstract protected function newRefViewURI( 161 - PhabricatorDocumentRef $ref, 162 - PhabricatorDocumentEngine $engine); 163 - 164 - abstract protected function newRefRenderURI( 165 - PhabricatorDocumentRef $ref, 166 - PhabricatorDocumentEngine $engine); 167 - 168 - protected function getSelectedDocumentEngineKey() { 169 - return $this->getRequest()->getURIData('engineKey'); 170 - } 171 - 172 160 final public function newRenderResponse(PhabricatorDocumentRef $ref) { 173 161 $request = $this->getRequest(); 174 162 $viewer = $request->getViewer(); ··· 278 266 } 279 267 280 268 return $crumbs; 269 + } 270 + 271 + abstract protected function newRefViewURI( 272 + PhabricatorDocumentRef $ref, 273 + PhabricatorDocumentEngine $engine); 274 + 275 + abstract protected function newRefRenderURI( 276 + PhabricatorDocumentRef $ref, 277 + PhabricatorDocumentEngine $engine); 278 + 279 + protected function getSelectedDocumentEngineKey() { 280 + return $this->getRequest()->getURIData('engineKey'); 281 + } 282 + 283 + protected function getSelectedLineRange() { 284 + return $this->getRequest()->getURILineRange('lines', 1000); 281 285 } 282 286 283 287 protected function addApplicationCrumbs(
+11 -2
webroot/rsrc/js/core/behavior-line-linker.js
··· 144 144 var o = getRowNumber(origin); 145 145 var t = getRowNumber(target); 146 146 var uri = JX.Stratcom.getData(root).uri; 147 + var path; 147 148 148 149 if (!uri) { 149 - uri = ('' + window.location).split('$')[0]; 150 + uri = JX.$U(window.location); 151 + path = uri.getPath(); 152 + path = path.replace(/\$[\d-]+$/, ''); 153 + uri.setPath(path); 154 + uri = uri.toString(); 150 155 } 151 156 152 157 origin = null; ··· 154 159 root = null; 155 160 156 161 var lines = (o == t ? o : Math.min(o, t) + '-' + Math.max(o, t)); 157 - uri = uri + '$' + lines; 162 + 163 + uri = JX.$U(uri); 164 + path = uri.getPath(); 165 + path = path + '$' + lines; 166 + uri = uri.setPath(path).toString(); 158 167 159 168 JX.History.replace(uri); 160 169