Steps to Reproduce:
You can select them normally in the side-by-side. Being able to do so is useful to restore/revert small pieces of code manually by copying and pasting.
That is a limitation of how the inline diff is implemented. I wonder if we can alleviate this limitation by adding a button somewhere in there (copy or revert this change) that would show up on hover
Instead of buttons, there can be code actions in the diffs for Previous | Next | Copy original | Revert to original
like the one provided with git merge. I have requested the feature at #30519
With all due respect, please just fix the inline diff implementation. No need for extra buttons. If you've had this bug around for a year, you should just make the right fix at this point.
Note that this also prevents ctrl-F from working correctly, since it can't find results in the removed lines. "Copy original" buttons don't avoid that issue.
Edit: this is a daily source of frustration, missing relevant changes because I don't get the results I should when using ctrl-F, and being unable to quickly select removed code for pasting into a search box. I rescind my "due respect", this is absolutely stupid behavior and ridiculous that there has been no action on this item. Literally any other diff program (windiff, odd, VS, etc) will allow you to select text from both files and get search results from both files.
This is one of the reasons that I have to open Visual Studio or another diff tool. When traveling the side by side is not an option on small laptops screens and not being able to find or copy the deleted code it is a significant loss.
I think this is a very necessary function !
Yes, this limitation basically forces the user to revert the whole batch of changes just to be able to get a single deleted line back. Its not a big deal if the line was just deleted - that is ctrl+z is for, but if I did a bunch of changes since already it's obviously not an option. I often just need to copy one single chunk of text and put it back into the file. Often not even at the location where it was removed from. But I can't.
I think it has something to do with the fact that the removed text is not a part of the surrounding, still present text - so you can't select them together, but I think if the user started selction inside the removed (red) line - he could/should be limited to selecting (and copying) the text only in the same red region.
Any news on this?
/cc @alexandrudima @rebornix @bpasero
A quick workaround is to switch to side by side view that allows copy/paste.
This is just painful and makes me so sad.
It is surprising to see such a common feature request pending from 2016. Or was it solved in some intermediate vscode releases and reappeared again in 1.31? Also right click doesn't work on left side.
Even in side by side view, I was able to select the deleted text, but can't copy it.
@drdebmath I searched the VS release notes, I don't think this was ever fixed in earlier versions. There have been multiple such requests over time, so a lot of people do want this.
My current "workaround" is to just have Sublime Text open as well - which I use as my git tool - using its amazing GitSavvy plugin.
It is a bit frustrating to be able to see deleted text and not being able to select it haha
@alexandrudima @rebornix @bpasero any updates here?
Can we test/help?
This was actually the straw that broken the camels back reason for me to keep using WebStorm over VSCode (until WebStorm completely was unable to open a project without crashing ...) This is a SUPER needed feature. I often make changes and want to revert a little bit all the time (via a quick copy paste NOT revert a huge block). Without this ability it's super painful!
Much much needed, please add this.!!
Would have been very useful to have this.
Please, this is a really important and necessary tool, and maybe a trivial one. Why are you so obstinated?
@titoleiva are you able to work around this by using side-by-side view?
@gjsjohnmurray, yes. It's the best option for now.
Yeah this is really annoying...
Not sure how this UX issue has been open since 2016...
You can copy deleted content or deleted line, or revert change by quick actions on the gutter, with latest Stable 1.38.
But it seems it's still not possible to stage deleted lines as this action does not exist in the gutter menu.
Yes, it is nice to see some improvements, but it took only a couple of usages to see how we still need the full editable capabilities to have a really enjoyable inline diff experience.
Visual studio code is really a pleasure to use, but I really miss my preferred way to work with diffs, fully functional 馃槈
@rebornix thanks for the update that adds new functionality! It is definitely a step in the right direction!
That said, it would still be even better if we could copy any portion of the old diff.
I find I often only want to copy a small portion of the old diff instead of the entire thing. This is still not possible.
If you could make it so we could highlight and copy any portion of the old diff that would be ideal!
Still seems to be an issue in 2019...
Guess its time to go back to webstorm. 馃
Please fix this. I went through a whole file replacing hard-coded strings with references to constants in an internationalization matrix. My intent was to then go back through the diff, copy-pasting the original text in the deleted lines into the matrix. Have to do something a bit more roundabout, now.
First comment of 2020! 馃ぃ 馃槶
I would make use of this every day if it were fixed...
Still waiting...
I agree with those here. The ability to select and copy any portion of the text within the inline diff would be very helpful indeed.
Wait, so is it impossible to stage deleted lines in vscode? There's no way to do it?
If someone knows of a workaround, please advise... After hearing so many good things about vscode, I switched from Atom, but now I'm back to using Atom. This is an absolute necessary feature for any developer... Who doesn't commit deleted code?
@cyberspectre2 If you want to copy an excerpt of a deleted code and paste in the current one you can do when opening the changes between the 2 files.
In some cases, this is not so convenient as seeing only the changes of a part of the file when clicking at the left of the page to show the changes of only that location and selecting what you want, even if is only a part of what was deleted (which this issue is addressing, although it already allows to copy the entire part), but for me the full file comparison is still fine in most cases.
Please allow us to select and copy any text within the diff.
@cyberspectre2 If you want to copy an excerpt of a deleted code and paste in the current one you can do when opening the changes between the 2 files.
In some cases, this is not so convenient as seeing only the changes of a part of the file when clicking at the left of the page to show the changes of only that location and selecting what you want, even if is only a part of what was deleted (which this issue is addressing, although it already allows to copy the entire part), but for me the full file comparison is still fine in most cases.
Not trying to copy deleted text. I want to stage / commit deleted text. Often, a change involves adding text to file 2, but removing text from file 1. In Atom, I can select deleted text from the diff view, and stage that deleted text only. How is this done in vscode?
Select the lines around the deleted ones, right click, stage them
Select the lines _around_ the deleted ones, right click, stage them
thanks @DianaNites this workaround works and is not that painful!
It's absolutely pathetic and amazes me that this issues has been around for so long and is still not addressed.
I'm actually playing with the idea right now to implement a plugin that uses OCR to extract the text from what is apparently an image of text in the deleted lines and thus makes it highlightable.
This is ridiculous.
I'm really not sure why this even happens. Surely it is easier from a dev point of view to make the text selectable like the rest?
Is it so that when you select both removed and added lines you don't get the github diff problem of them both being merged with no way of telling which is which? That I understand, but still, there should be an easier way of doing it.
I'd like to throw another voice into the choir saying that this is a highly desirable feature. I'd even go so far as to say it's more valuable to be able to copy deleted lines than new lines, since I have easy access to the new ones on my machine but the deleted ones are only visible to me through git.
The stubbornness of the team is disturbing. Just paid for this thing too, don't see myself renewing. I don't need the daily frustration.
Just paid for this thing too, don't see myself renewing.
@marcelo-mason who did you pay, and how much?
I often delete some code and want to restore it, but can't implement it by ctrl + z
and just discard file changes easily, so this feature is very useful for me.
Most helpful comment
This is just painful and makes me so sad.