Add commands to open next, previous file in active PR

Issue #434 open
Ian Chamberlain created an issue

When opening a changed file while reviewing a PR, it is possible to use the workbench.action.compareEditor.{next,previous}Change VSCode commands to move to the next/previous change within a file, much like the Bitbucket server n and p keyboard shortcuts.

This issue is a request to add custom command contribution points to the extension e.g. something like atlascode.bb.{next,previous}pullRequest.nextItem so it is possible to bind keyboard shortcuts which match the j and k shortcuts in some older versions of BB server (I am not as familiar with newer versions, or BB cloud, but it looks like there is a similar shortcut J "Select next item", something like that would serve the same purpose). This would improve productivity using the extension significantly for users who are accustomed to existing shortcuts in the web interface.

Comments (6)

  1. Pramod Busam Account Deactivated

    @{557058:c0430571-619b-452e-8e71-9bdd9e451cde} Creating custom keyboard shortcuts in VS Code should work for this use case:

    • Run Preferences: Open Keyboard Shortcuts (JSON) from command palette to open the config file
    • Add the shortcut similar to the following:
      {
        "key": "j",
        "command": "workbench.action.compareEditor.nextChange",
        "when": "editorTextFocus && resourceScheme == atlascode.bbpr"
      }
    

    Let us know if that works for you.

    (VS Code includes default keyboard shortcuts for those actions alt+f5 and shift+alt+f5. You can also try using those to avoid custom setting.)

  2. Ian Chamberlain Account Deactivated reporter

    resourceScheme == atlascode.bbpr is useful to know about, thanks for that.

    Unfortunately workbench.action.compareEditor.nextChange (and workbench.action.editor.nextChange, as far as I can tell) does not navigate to the next file like j and k – it navigates to the next change within a single file and wraps back to the top of the same file when it reaches the bottom. This command more closely matches the n and p keyboard shortcuts' behavior, as I described in the original issue.

    As far as I know, there is no built-in VSCode command to navigate to the next file in a diff, which isn't too surprising, since the context of which file to go to is probably only available within the context of the Atlassian extension.

  3. Ian Chamberlain Account Deactivated reporter

    In case anyone else comes looking for something similar, I found a bit of a workaround which gets me similar to ideal behavior.

    First, I installed an extension to create command macros, in my case https://marketplace.visualstudio.com/items?itemName=geddski.macros did the trick

    Then create macros to navigate the sidebar:

    {
        "macros": {
            "atlascode.bb.pullRequest.nextFile": [
                "workbench.action.closeActiveEditor",
                "atlascode.views.bb.pullrequestsTreeView.focus",
                "list.focusDown",
                "list.select",
            ],
            "atlascode.bb.pullRequest.previousFile": [
                "workbench.action.closeActiveEditor",
                "atlascode.views.bb.pullrequestsTreeView.focus",
                "list.focusUp",
                "list.select",
            ]
        },
    }
    

    Finally you can bind keyboard shortcuts to the commands macros.atlascode.bb.pullRequest.nextFile and macros.atlascode.bb.pullRequest.previousFile.

    This works okay, but only if the pull request files are viewed flat (it does not handle tree structure if "Toggle File Nesting" is used). Ideally the extension could provide a command which does something very similar but properly navigates to the next "leaf" (i.e. file) in the tree.

  4. Log in to comment