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

:reload should fail if unsaved changes #5680

Open
vwkd opened this issue Jan 25, 2023 · 10 comments · May be fixed by #5911 or #7948
Open

:reload should fail if unsaved changes #5680

vwkd opened this issue Jan 25, 2023 · 10 comments · May be fixed by #5911 or #7948
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements E-easy Call for participation: Experience needed to fix: Easy / not much E-good-first-issue Call for participation: Issues suitable for new contributors

Comments

@vwkd
Copy link
Contributor

vwkd commented Jan 25, 2023

I'd like to suggest the reload command to fail if there are unsaved changes and adding an explicit reload! that discards unsaved changes, similar to q or bc.

Currently, reload discards changes anyway.

Sometimes it's useful to reload a file only if there aren't any changes. For example, when changing the underlying file through another source I reload to not revert the changes on the next save in helix. However, if I have unsaved changes, I'd like that helix prevents me from reloading so I don't lose the changes. I know I can undo, but sometimes the changes are not visible in the current window. An explicit confirmation would be better.

@vwkd vwkd added the C-enhancement Category: Improvements label Jan 25, 2023
@David-Else
Copy link
Contributor

I think your request relates to: #4734

@ninevra
Copy link

ninevra commented Jan 26, 2023

I think your request relates to: #4734

I think it's kind of the opposite? #4734 is about preventing :write from overwriting changes made to disk by other programs, whereas this is about preventing :reload from overwriting changes made in helix' memory and not yet written to disk.

@ninevra
Copy link

ninevra commented Jan 26, 2023

This would be doubly useful with :reload-all.

I end up using :reload and :reload-all a lot, e.g. after git checkout, to avoid accidentally later working on a buffer that's out of date. After git checkout, if there's a buffer with unsaved changes, it's either an untracked file or something I forgot to save & commit, so I really don't want to accidentally lose that work; but at the same time, there may be many open buffers, and I really don't want to leave one open with another branch's state in it.

:reload and :reload-all failing or prompting instead of overwriting unsaved buffers would be very useful.

@David-Else
Copy link
Contributor

I think your request relates to: #4734

I think it's kind of the opposite? #4734 is about preventing :write from overwriting changes made to disk by other programs, whereas this is about preventing :reload from overwriting changes made in helix' memory and not yet written to disk.

I meant it is in the same genre of feature, preventing unwanted data loss. I was probably being too general and not much help, soz!

@ninevra
Copy link

ninevra commented Jan 28, 2023

I meant it is in the same genre of feature, preventing unwanted data loss. I was probably being too general and not much help, soz!

Np! Cross-referencing is great.

@kirawi kirawi added E-easy Call for participation: Experience needed to fix: Easy / not much A-helix-term Area: Helix term improvements E-good-first-issue Call for participation: Issues suitable for new contributors labels Feb 5, 2023
@Pablu23
Copy link

Pablu23 commented Feb 10, 2023

Ill try to do this

@Pablu23
Copy link

Pablu23 commented Feb 11, 2023

I opened a pr for this

@askreet
Copy link
Contributor

askreet commented Feb 15, 2023

@Pablu23 Can you mention this Issue # in your PR (as #5680)? That helps the GitHub UI show which issues have related PRs.

@sudormrfbin sudormrfbin linked a pull request Feb 16, 2023 that will close this issue
@Pablu23
Copy link

Pablu23 commented Feb 16, 2023

Ahh yes I just did it, this is my first time contributing so I didnt know that. Thanks :)

@quantonganh quantonganh linked a pull request Aug 15, 2023 that will close this issue
@gozes
Copy link

gozes commented Aug 24, 2023

hmm, I think this may be related to something that bit me today where I put something up for PR, committed some suggestions from the GitHub UI, and then pulled so that I could address other issues but Helix didn't reload the file/buffer with the local changes so I ended up losing some work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements E-easy Call for participation: Experience needed to fix: Easy / not much E-good-first-issue Call for participation: Issues suitable for new contributors
Projects
None yet
7 participants