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

feat(actions): add git restore action, use in git_status picker #2870

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

LucasDooms
Copy link

Description

Motivation: convenient way to git restore files using telescope.

Add an action to perform a git restore on a file. Accessible via the builtin.git_status picker, with <del> key.
If there are any unsaved changes, the user can save, discard, or cancel, before choosing to git recover.
If the restore is confirmed by the user, will call git restore and immediately refresh the buffers with :checktime in case the file is open.

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

To test, open a git repo and make some changes to a file to show in the git status telescope picker.
In the git_status picker, select the file you want to restore and press the <del> key (only in normal mode). The possible options are:

  • press enter (or type 'n' and enter), nothing happens.
  • type 'y' and enter, the file is restored, and immediately refreshed.

If the file is open in a buffer and has unsaved changes:

  • press enter, nothing happens.
  • type 's' and enter, the file is saved, and you are prompted for the git restore action (if you go to the file and press 'u', the changes are recovered)
  • type 'd' and enter, the changes are discarded, and you are prompted for the git restore action (you cannot recover the unsaved changes)

Configuration:

  • Neovim version (nvim --version): NVIM v0.9.4
  • Operating system and version: Windows 10 - 10.0.19045 Build 19045

Checklist:

  • My code follows the style guidelines of this project (stylua)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (lua annotations)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant