Skip to content
Grégoire Geis edited this page Nov 10, 2023 · 1 revision

Exposes a review menu (bound to the key ,) when viewing a file in a Pull Request review.

This menu allows quick navigation between PR diffs and files.

  {
    "key": ",",
    "command": "dance.openMenu",
    "args": {
      "menu": {
        "items": {
          "N": {
            "text": "next diff",
            "command": "pr.goToNextDiffInPr",
          },
          "n": {
            // Go to next diff in PR, marking the file as viewed if this was its last diff.
            "text": "next diff (mark as viewed)",
            "command": "dance.run",
            "args": {
              "input": [
                "const uri = vscode.window.activeTextEditor?.document.uri",
                "await command('pr.goToNextDiffInPr')",
                "if (vscode.window.activeTextEditor?.document.uri.toString() !== uri.toString()) {",
                "  await command('pr.markFileAsViewed', uri)",
                "}",
              ],
            },
          },
          "P": {
            "text": "previous diff",
            "command": "pr.goToPreviousDiffInPr",
          },
          "p": {
            "text": "previous diff (mark as viewed)",
            "command": "dance.run",
            "args": {
              "input": [
                "const uri = vscode.window.activeTextEditor?.document.uri",
                "await command('pr.goToPreviousDiffInPr')",
                "if (vscode.window.activeTextEditor?.document.uri.toString() !== uri.toString()) {",
                "  await command('pr.markFileAsViewed', uri)",
                "}",
              ],
            },
          },
          "v": {
            // Note: this command will close the current editor automatically.
            "text": "mark file as viewed",
            "command": "pr.markFileAsViewed",
          },
          "V": {
            "text": "unmark file as viewed",
            "command": "pr.unmarkFileAsViewed",
          },
          "o": {
            "text": "open original file",
            "command": "pr.openOriginalFile",
          },
        },
      },
    },
    "when": "editorTextFocus && dance.mode == 'normal' && (resourcePath in github:viewedFiles || resourcePath in github:unviewedFiles)",
  },