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
This commit is contained in:
@@ -61,6 +61,10 @@ final class AphrontRequest extends Phobject {
|
||||
*/
|
||||
public function getURILineRange($key, $limit) {
|
||||
$range = $this->getURIData($key);
|
||||
return self::parseURILineRange($range, $limit);
|
||||
}
|
||||
|
||||
public static function parseURILineRange($range, $limit) {
|
||||
if (!strlen($range)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -14,10 +14,6 @@ final class DiffusionDocumentRenderingEngine
|
||||
return $this->diffusionRequest;
|
||||
}
|
||||
|
||||
protected function getSelectedDocumentEngineKey() {
|
||||
return $this->getRequest()->getStr('as');
|
||||
}
|
||||
|
||||
protected function newRefViewURI(
|
||||
PhabricatorDocumentRef $ref,
|
||||
PhabricatorDocumentEngine $engine) {
|
||||
@@ -58,6 +54,15 @@ final class DiffusionDocumentRenderingEngine
|
||||
));
|
||||
}
|
||||
|
||||
protected function getSelectedDocumentEngineKey() {
|
||||
return $this->getRequest()->getStr('as');
|
||||
}
|
||||
|
||||
protected function getSelectedLineRange() {
|
||||
$range = $this->getDiffusionRequest()->getLine();
|
||||
return AphrontRequest::parseURILineRange($range, 1000);
|
||||
}
|
||||
|
||||
protected function addApplicationCrumbs(
|
||||
PHUICrumbsView $crumbs,
|
||||
PhabricatorDocumentRef $ref = null) {
|
||||
|
||||
@@ -54,7 +54,7 @@ abstract class PhabricatorDocumentRenderingEngine
|
||||
}
|
||||
$engine = $engines[$engine_key];
|
||||
|
||||
$lines = $request->getURILineRange('lines', 1000);
|
||||
$lines = $this->getSelectedLineRange();
|
||||
if ($lines) {
|
||||
$engine->setHighlightedLines(range($lines[0], $lines[1]));
|
||||
}
|
||||
@@ -157,18 +157,6 @@ abstract class PhabricatorDocumentRenderingEngine
|
||||
->appendChild($viewport);
|
||||
}
|
||||
|
||||
abstract protected function newRefViewURI(
|
||||
PhabricatorDocumentRef $ref,
|
||||
PhabricatorDocumentEngine $engine);
|
||||
|
||||
abstract protected function newRefRenderURI(
|
||||
PhabricatorDocumentRef $ref,
|
||||
PhabricatorDocumentEngine $engine);
|
||||
|
||||
protected function getSelectedDocumentEngineKey() {
|
||||
return $this->getRequest()->getURIData('engineKey');
|
||||
}
|
||||
|
||||
final public function newRenderResponse(PhabricatorDocumentRef $ref) {
|
||||
$request = $this->getRequest();
|
||||
$viewer = $request->getViewer();
|
||||
@@ -280,6 +268,22 @@ abstract class PhabricatorDocumentRenderingEngine
|
||||
return $crumbs;
|
||||
}
|
||||
|
||||
abstract protected function newRefViewURI(
|
||||
PhabricatorDocumentRef $ref,
|
||||
PhabricatorDocumentEngine $engine);
|
||||
|
||||
abstract protected function newRefRenderURI(
|
||||
PhabricatorDocumentRef $ref,
|
||||
PhabricatorDocumentEngine $engine);
|
||||
|
||||
protected function getSelectedDocumentEngineKey() {
|
||||
return $this->getRequest()->getURIData('engineKey');
|
||||
}
|
||||
|
||||
protected function getSelectedLineRange() {
|
||||
return $this->getRequest()->getURILineRange('lines', 1000);
|
||||
}
|
||||
|
||||
protected function addApplicationCrumbs(
|
||||
PHUICrumbsView $crumbs,
|
||||
PhabricatorDocumentRef $ref = null) {
|
||||
|
||||
Reference in New Issue
Block a user