Merge "Shrink height of gr-edit-file-controls"
diff --git a/polygerrit-ui/app/elements/core/gr-navigation/gr-navigation.html b/polygerrit-ui/app/elements/core/gr-navigation/gr-navigation.html
index 7b17f22..006b9d9 100644
--- a/polygerrit-ui/app/elements/core/gr-navigation/gr-navigation.html
+++ b/polygerrit-ui/app/elements/core/gr-navigation/gr-navigation.html
@@ -319,10 +319,12 @@
       /**
        * @param {{ _number: number, project: string }} change The change object.
        * @param {string} path The file path.
+       * @param {number=} opt_patchNum
        * @return {string}
        */
-      getEditUrlForDiff(change, path) {
-        return this.getEditUrlForDiffById(change._number, change.project, path);
+      getEditUrlForDiff(change, path, opt_patchNum) {
+        return this.getEditUrlForDiffById(change._number, change.project, path,
+            opt_patchNum);
       },
 
       /**
@@ -331,13 +333,13 @@
        * @param {string} path The file path.
        * @return {string}
        */
-      getEditUrlForDiffById(changeNum, project, path) {
+      getEditUrlForDiffById(changeNum, project, path, opt_patchNum) {
         return this._getUrlFor({
           view: Gerrit.Nav.View.EDIT,
           changeNum,
           project,
           path,
-          patchNum: EDIT_PATCHNUM,
+          patchNum: opt_patchNum || EDIT_PATCHNUM,
         });
       },
 
diff --git a/polygerrit-ui/app/elements/core/gr-router/gr-router.js b/polygerrit-ui/app/elements/core/gr-router/gr-router.js
index dc264f2..28fb497 100644
--- a/polygerrit-ui/app/elements/core/gr-router/gr-router.js
+++ b/polygerrit-ui/app/elements/core/gr-router/gr-router.js
@@ -114,9 +114,8 @@
     // eslint-disable-next-line max-len
     CHANGE_OR_DIFF: /^\/c\/(.+)\/\+\/(\d+)(\/?((-?\d+|edit)(\.\.(\d+|edit))?(\/(.+))?))?\/?$/,
 
-    // Matches /c/<project>/+/<changeNum>/edit/<path>,edit
-    // eslint-disable-next-line max-len
-    DIFF_EDIT: /^\/c\/(.+)\/\+\/(\d+)\/edit\/(.+),edit$/,
+    // Matches /c/<project>/+/<changeNum>/[<patchNum|edit>]/<path>,edit
+    DIFF_EDIT: /^\/c\/(.+)\/\+\/(\d+)\/(\d+|edit)\/(.+),edit$/,
 
     // Matches non-project-relative
     // /c/<changeNum>/[<basePatchNum>..]<patchNum>/<path>.
@@ -1250,7 +1249,8 @@
       this._redirectOrNavigate({
         project: ctx.params[0],
         changeNum: ctx.params[1],
-        path: ctx.params[2],
+        patchNum: ctx.params[2],
+        path: ctx.params[3],
         view: Gerrit.Nav.View.EDIT,
       });
     },
diff --git a/polygerrit-ui/app/elements/core/gr-router/gr-router_test.html b/polygerrit-ui/app/elements/core/gr-router/gr-router_test.html
index 7011c65..d38b3f0 100644
--- a/polygerrit-ui/app/elements/core/gr-router/gr-router_test.html
+++ b/polygerrit-ui/app/elements/core/gr-router/gr-router_test.html
@@ -1313,7 +1313,8 @@
             params: [
               'foo/bar', // 0 Project
               1234, // 1 Change number
-              'foo/bar/baz', // 2 File path
+              3, // 2 Patch num
+              'foo/bar/baz', // 3 File path
             ],
           };
           const appParams = {
@@ -1321,6 +1322,7 @@
             changeNum: 1234,
             view: Gerrit.Nav.View.EDIT,
             path: 'foo/bar/baz',
+            patchNum: 3,
           };
 
           element._handleDiffEditRoute(ctx);