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: Unstage Selected Range" does not revert "Git: Stage Selected Range" on the same range #156748

Open
SimonTheLeg opened this issue Jul 31, 2022 · 3 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug git GIT issues
Milestone

Comments

@SimonTheLeg
Copy link

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.69.2
  • OS Version: Darwin x64 21.6.0
  • Git Version: 2.37.1

Steps to Reproduce:

  1. Prepare a simple git repo with a file and start VSCode with no extensions
mkdir test
cd test
git init
echo -e "line 1" > file
git add file
git commit -m "commit"
echo -e "line 2\n\nline 4" >> file
code --disable-extensions .
  1. Select line 2 like so
    image

  2. Run "Git: Stage Selected Ranges". Everything should look fine, the range is being staged, like so
    image

  3. With the same selection (pic), run "Git: Unstage Selected Ranges"
    image

  4. The selection is not being unstaged, everything stays as before. I would have expected that the selection is being unstaged
    image

Additional Notes:
This is similar to #120928, but not exactly the same. Because in my case the "Stage Selected Ranges" does work outside of the diff view, just the "Unstaging" does not. Therefore I decided to open a separate issue.

@lszomoru lszomoru added bug Issue identified by VS Code Team member as probable bug git GIT issues labels Sep 23, 2022
@lszomoru lszomoru added the confirmed Issue has been confirmed by VS Code Team member label Dec 12, 2022
@lszomoru lszomoru added this to the January 2023 milestone Dec 12, 2022
@lszomoru
Copy link
Member

@SimonTheLeg, thank you very much for the detailed repro steps. I have looked into this and while I do agree with you that the experience is not ideal, looking at the code, this seems to be the intended behaviour. The "Stage/Unstage Selected Ranges" commands are always present in the command palette but there are several conditions that have to be fulfilled in order for the command to execute (ex: there has to be an opened document, there has to be a selection, the selection has to contain changes, etc.). If any of these conditions are unmet, the command will not execute. In the case of the "Unstage Selected Ranges", the selection has to be made on the right side of the diff editor (Index), and the selection has to contain changes.

There are couple of things that we could to in order to avoid the confusion:

  1. Hide the command for obvious cases (ex: there is no document opened, no selection)
  2. Display an information notification for other cases (ex: selection does not contain changes)

@joaomoreno, what are your thoughts?

@lszomoru lszomoru added under-discussion Issue is under discussion for relevance, priority, approach and removed bug Issue identified by VS Code Team member as probable bug confirmed Issue has been confirmed by VS Code Team member labels Dec 19, 2022
@lszomoru lszomoru modified the milestones: January 2023, February 2023 Jan 25, 2023
@lszomoru lszomoru removed the under-discussion Issue is under discussion for relevance, priority, approach label Jan 31, 2023
@SampsonCrowley
Copy link

@Iszomorou those sound like massive limitations. I'm coming over from atom, since now it's sunset... 😢 and I could open a single combined diff view and unstage or stage any line I wanted by selecting it, right clicking and selecting "stage/unstage selected" it was a hugely useful workflow and not being able to undelete a section that has been removed because you can only stage/unstage on the "right" side is, to put it frankly, dumb. it's completely unintuitive to anybody coming from a another IDE where things "just work(tm)"

@lszomoru lszomoru modified the milestones: February 2023, March 2023 Feb 23, 2023
@lszomoru lszomoru modified the milestones: March 2023, April 2023 Mar 21, 2023
@lszomoru
Copy link
Member

@SampsonCrowley, thank you very much for your feedback and apologies for not getting back to you on this until now. I will take another look here to see if there is anything that we can do to enable this functionality.

@lszomoru lszomoru modified the milestones: April 2023, May 2023 Apr 26, 2023
@lszomoru lszomoru modified the milestones: May 2023, Backlog May 26, 2023
@lszomoru lszomoru added the bug Issue identified by VS Code Team member as probable bug label Dec 5, 2023
@lszomoru lszomoru modified the milestones: Backlog, On Deck Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug git GIT issues
Projects
None yet
Development

No branches or pull requests

3 participants