Skip to content

Allow focusing the main viewย #3988

Open
@stefanhaller

Description

@stefanhaller

Currently the main view can't be focused. It can be scrolled with pgup/pgdn or with c-d/c-u, but that's very non-standard and hard to discover. Also, it goes only line by line; it would be useful to be able to scroll by pages.

It would be nice if there was a way to focus the main view, including having a selection that can be moved up/down like in all other views (up/down for line by line, ,/. by page, </> for beginning/end). This would also allow searching the main view.

And, together with #3986, it would make it possible to select a line in the main view, and then either hit e to edit the file at that line, or enter to go to the staging view.

Challenges/open questions:

  • Clicking in the main view. Right now, clicking in the diff of a commit does nothing, so this can easily focus the main view and select the clicked line. However, if a file is selected in the files panel, then clicking in the diff currently enters staging (with all the caveats mentioned in Improve clicking in diff view to enter staging/patch buildingย #3986), so selecting the line would be a behavior change that might be annoying for existing users; you'd need an extra enter key press to enter staging.
  • Focusing the main view with the keyboard. This needs a new key, since enter is already taken. Maybe 0 would make sense (in analogy to 1-5 for the side panels).
    • One detail consideration: which line do we select when hitting the key? Users might already have scrolled with the wheel, in which case it would be annoying to select the first line (and jump back to the top). Maybe we should always select the line that is in the middle of the screen?
  • Hitting escape to go "out". In some cases it will be possible to jump from the main view to another view, e.g. from a diff to the staging view. When hitting escape, should we put the focus back to the main view that we came from, or focus the side panel like we do today? I suppose the latter would be easier to implement, since we may have to rerender the main view after coming back from staging.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions