diff --git a/src/view/layout/PhabricatorSourceCodeView.php b/src/view/layout/PhabricatorSourceCodeView.php --- a/src/view/layout/PhabricatorSourceCodeView.php +++ b/src/view/layout/PhabricatorSourceCodeView.php @@ -132,7 +132,7 @@ if ($this->canClickHighlight) { if ($base_uri) { - $line_href = $base_uri.'$'.$line_number; + $line_href = $base_uri.'#'.$line_number; } else { $line_href = null; } @@ -142,6 +142,7 @@ array( 'href' => $line_href, 'data-n' => $line_number, + 'id' => $line_number, )); } else { $tag_number = phutil_tag( diff --git a/webroot/rsrc/js/core/behavior-line-linker.js b/webroot/rsrc/js/core/behavior-line-linker.js --- a/webroot/rsrc/js/core/behavior-line-linker.js +++ b/webroot/rsrc/js/core/behavior-line-linker.js @@ -160,11 +160,16 @@ target = null; root = null; - var lines = (o == t ? o : Math.min(o, t) + '-' + Math.max(o, t)); - uri = JX.$U(uri); path = uri.getPath(); - path = path + '$' + lines; + // Use anchor fragment for single line (calling the resulting URL will + // not highlight or scroll). Use custom $ when selecting multiple lines + // (calling the resulting URL will highlight and scroll to position). + if (o == t) { + path = path + '#' + o; + } else { + path = path + '$' + Math.min(o, t) + '-' + Math.max(o, t); + } uri = uri.setPath(path).toString(); JX.History.replace(uri);