Git: file patch view - toggle staged/unstaged changes


#1

Plugin: GitHub

When viewing staged/unstaged changes for a file, there is a toolbar button which toggles between viewing staged and unstaged lines; see image:

toggle-staged

Is there a way to trigger this via a command? I haven’t been able to find a built-in command for it.

It looks like this is the code which that button triggers: https://github.com/atom/github/blob/3fab2722fb76b4f2ff1305747b7b98ab86a96330/lib/controllers/file-patch-controller.js#L508-L513
Is it possible to somehow call that function from a custom command? I’m new to Atom, so I’m not sure if it’s possible to call something like that which isn’t part of the Atom API.

Or is there a way to trigger the change via keyboard which I am missing?


#2

You can if the package defines it as a command, which github appears to do. You can add new keybindings for those commands as described in the Flight Manual.


#3

I had previously tried those commands, but I didn’t see anything happening. Since you mentioned them also, I decided to give the a try again. This time I noticed that I am getting an uncaught exception:

Uncaught (in promise) TypeError: Cannot read property 'getPath' of undefined
at /usr/share/atom/resources/app/node_modules/github/lib/controllers/root-controller.js:662:68

It looks like there might be an open defect for the same type of error: https://github.com/atom/github/issues/964

I’ve tried running in safe mode as well, with no change in outcome.


#4

After taking another look at your screenshot, I don’t think you’re using the github package. github creates a view that looks like this: