Vscode-gitlens: Restore deleted line?

Created on 10 Dec 2018  路  13Comments  路  Source: eamodio/vscode-gitlens

If I accidentally delete a line, is there a way to restore it with GitLens?

Here is an example:

image

I would like to restore line 145, which has been deleted as an uncommitted change. However, I can't select the deleted line with the mouse, I can only select the actual lines in the file that are currently present.

Surely I shouldn't have to revert to select and copy / restore the deleted line right? Is there any solution to this? Otherwise consider this a feature request 馃檪

question

Most helpful comment

I have the same question. If one could at least copy text of deleted lines, it would be really helpful, but at the moment, its just as @GandalfSaxe said... you can restore the whole chunk or nothing.

Is there any chance to rethink this feature request or add the ability for selecting deleted lines?

All 13 comments

You can just using the built in git extension -- if you aren't in diff view, you will see a little red arrow at the point where you deleted the line. If you hover over it, it will expand to a red rectangle that you can click on and it will open a peek view with the change which you can undo.

Hope that helps.

Actually it doesn't help me because it's an all-or-nothing feature: I can only discard ALL changes in the block. If I'm only interested in restoring a single line, it's not possible in this pop-up view you speak of to select text here either. Thus I'm forced to go to the web interface of GitHub.com to find the line I'm looking to restore.

If you open the diff view (click the Open Changes button in the editor toolbar) then you should be able to see the contents of the deleted line on the left and copy it to the right.

The Open Changes view doesn't allow me to select any of the deleted lines either:

I have the same question. If one could at least copy text of deleted lines, it would be really helpful, but at the moment, its just as @GandalfSaxe said... you can restore the whole chunk or nothing.

Is there any chance to rethink this feature request or add the ability for selecting deleted lines?

As others have pointed out, it would be of immense help it could be possible to select and copy some content of _red blocks_.

@pmilic021 Unfortunately that isn't something GitLens can fix -- that is an issue with vscode itself. I would recommend opening an issue with the vscode repo -- if there isn't one already (in which case upvote it).

Alright, never would have guessed

Use side-by-side View to copy content.

If you open the diff view (click the Open Changes button in the editor toolbar) then you should be able to see the contents of the deleted line on the left and copy it to the right.

@eamodio can Git Lens provide a way to do this without having to copy + paste? Useful if you're doing this for multiple (but not all) lines throughout a file. e.g. select the deleted lines in left view, right click and select 'discard lines'/'discard changes'?

edit: I think the interface is managed by vscode but gitlens can manage the right click options

I've also opened a feature request for vscode that should help with this https://github.com/microsoft/vscode/issues/94365

image

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

susiwen8 picture susiwen8  路  3Comments

robertzauner picture robertzauner  路  3Comments

rfgamaral picture rfgamaral  路  3Comments

vgrafe picture vgrafe  路  3Comments

roblourens picture roblourens  路  4Comments