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

Refine undo behavior #64

Closed
jebaum opened this issue Feb 2, 2016 · 4 comments
Closed

Refine undo behavior #64

jebaum opened this issue Feb 2, 2016 · 4 comments

Comments

@jebaum
Copy link
Contributor

jebaum commented Feb 2, 2016

Pressing u does a couple of things that I don't think are ideal:

  1. immediately after running Magit, it will clear the whole buffer
  2. toggling display of "help" can be undone with u

If undo within the context of the Magit buffer would only undo Magit actions (and same with redo of course) it would improve usability. The above two cases are the only two I've noticed where I hit u and something I don't want to happen happens, but there may be a couple others I haven't bumped into yet.

The only way I can think of to achieve this would be a little bit hacky with wundo, rundo, and the code snippet in :h clear-undo. I'll try to see if there are better options, or if this could be made optional for people who don't have undofile on. It's possible it may not be worth it at all, in which case I may want to explore adding a feature to vim/neovim to enable fine grained control of the undo history.

jreybert added a commit that referenced this issue Feb 2, 2016
…(refs #64)

Then, user can't undo some changes in magit buffer made the backend (these changes would only be virtual).
But it can still undo some changes when he is typing.

Catch undo and make undo really undoing magit commands would be soooo cool, but seems quite difficult to implement.
@jreybert
Copy link
Owner

jreybert commented Feb 2, 2016

Hi,

there is a first and clean fix about your issue. Actually, you are right, letting the undo thing like this may let the user think that when it presses u, its last magit command is undone (which is not the case!).

This patch (that you can try with the branch dev/undo) clears the undo history at each magit buffer update. Then, pressing u won't undo the magit changes. But if the user is writing a commit message for example, it can still use u to undo what he is typing.

@jreybert jreybert added the bug label Feb 2, 2016
@jreybert jreybert added this to the Release 1.5.2 milestone Feb 2, 2016
@jreybert
Copy link
Owner

jreybert commented Feb 8, 2016

@jebaum did you try this branch? I intend to merge it to next release, let me know your point of view.

@jebaum
Copy link
Contributor Author

jebaum commented Feb 8, 2016

I'll start running that branch now and let you know. Glanced at the code, looks pretty good to me. Is it possible to get around that unwanted fold opening with something like :silent! normal! zc? with foldclosed() and foldlevel() it ought to be possible to make sure the folding stays the same even with nesting.

jreybert added a commit that referenced this issue Feb 9, 2016
…(refs #64)

Then, user can't undo some changes in magit buffer made the backend (these changes would only be virtual).
But it can still undo some changes when he is typing.

Catch undo and make undo really undoing magit commands would be soooo cool, but seems quite difficult to implement.
@jreybert
Copy link
Owner

Well, for the fold opening stuff, are you experiencing this? Are do you based your comment on function comment?

The function comment may be unclear, but it says that unwanted unfold may appear if the function is used at the wrong place.

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

No branches or pull requests

2 participants