Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git: Provide single shortcut for "Stage Changes"/"Unstage Changes" #44592

Closed
birgersp opened this issue Feb 27, 2018 · 13 comments
Closed

Git: Provide single shortcut for "Stage Changes"/"Unstage Changes" #44592

birgersp opened this issue Feb 27, 2018 · 13 comments
Labels
feature-request Request for new features or functionality git GIT issues help wanted Issues identified as good community contribution opportunities *out-of-scope Posted issue is not in scope of VS Code
Milestone

Comments

@birgersp
Copy link

I personally prefer to use the same keyboard shortcut for both "Stage Changes" and "Unstage Changes".

If I set the same keyboard shortcut for both, only one of them (namely, "Stage Changes") is enabled.

@vscodebot
Copy link

vscodebot bot commented Feb 27, 2018

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@vscodebot vscodebot bot added the git GIT issues label Feb 27, 2018
@joaomoreno
Copy link
Member

@birgersp How did you configure those keybindings? Can you show me your keybindings.json?

@joaomoreno joaomoreno added the info-needed Issue requires more information from poster label Feb 27, 2018
@birgersp
Copy link
Author

@joaomoreno Thanks for getting back to me so quickly! I configured the keybindings by opening the keybindings editor with "File"->"Preferences"->"Keyboard Shortcuts".

Then I double-clicked the "Stage Changes" command, and pressed CTRL+T followed by ENTER to assign it. Did the same for "Unstage Changes".

My keybindings.json file looks like this:

// Place your key bindings in this file to overwrite the defaults
[
    {
        "key": "ctrl+t",
        "command": "git.stage"
    },
    {
        "key": "ctrl+u",
        "command": "git.unstage"
    }
]

@joaomoreno
Copy link
Member

joaomoreno commented Feb 27, 2018

Got it. What would your prefer to happen if the file is both staged and modified in the working tree?

@birgersp
Copy link
Author

I am thinking wheter it should be staged or unstaged depends on the current selection. Meaning;

When the command is invoked, and

  • If the file is selected among unstaged files: stage it
  • If the file is selected among staged files: unstage it

For instance, pressing the keyboard shortcut here, would cause the file to be unstaged (since it is selected as a staged file):
screenshot from 2018-02-28 09-43-33

@joaomoreno
Copy link
Member

Notice that the command doesn't know about selection, only about the currently opened file. There's no current API to get a hold of that selection.

@birgersp
Copy link
Author

Understood. Personally, I don't have any opinion as to what should happen if the file is both staged and unstaged.

@joaomoreno joaomoreno added this to the Backlog milestone Feb 28, 2018
@joaomoreno joaomoreno added feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities and removed info-needed Issue requires more information from poster labels Feb 28, 2018
@joaomoreno
Copy link
Member

I suggest we just stage it.

@kumarharsh
Copy link
Contributor

kumarharsh commented Apr 20, 2018

I actually wanted to see whether there are hidden when clauses we could be used to detect which mode we are in, and set keybindings accordingly... Something like:

[
    {
        "key": "ctrl+t",
        "command": "git.stage",
		"when": "inDiffEditor" // only for illustrative purposes, i don't know if there is a when clause for this mode
    },
    {
        "key": "ctrl+t",
        "command": "git.unstage",
		"when": "inDiffEditor && inStagedView" // only for illustrative purposes, i don't know if there is a when clause for this mode
    }
]

@AB1908
Copy link

AB1908 commented Jun 8, 2018

I actually wanted to see whether there are hidden when clauses we could be used to detect which mode we are in, and set keybindings accordingly

@kumarharsh: Found anything about that when clause?

@kumarharsh
Copy link
Contributor

Nopes ☹. The core team needs to answer this.

@joaomoreno
Copy link
Member

@kumarharsh Maybe try something like resourceScheme == git.

@joaomoreno joaomoreno changed the title "Stage Changes"/"Unstage Changes" cannot have the same keyboard shortcut Git: Provide single shortcut for "Stage Changes"/"Unstage Changes" Sep 18, 2018
@joaomoreno joaomoreno removed their assignment Sep 19, 2018
@joaomoreno joaomoreno added the *out-of-scope Posted issue is not in scope of VS Code label Oct 9, 2019
@vscodebot
Copy link

vscodebot bot commented Oct 9, 2019

This issue is being closed to keep the number of issues in our inbox on a manageable level, we are closing issues that are not going to be addressed in the foreseeable future: We look at the number of votes the issue has received and the number of duplicate issues filed. More details here. If you disagree and feel that this issue is crucial: We are happy to listen and to reconsider.

If you wonder what we are up to, please see our roadmap and issue reporting guidelines.

Thanks for your understanding and happy coding!

@vscodebot vscodebot bot closed this as completed Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality git GIT issues help wanted Issues identified as good community contribution opportunities *out-of-scope Posted issue is not in scope of VS Code
Projects
None yet
Development

No branches or pull requests

4 participants