-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Fix for saving from insert mode #7226
Conversation
While committing changes from insert mode is perhaps not idiomatic, this fixes a bug. Any shortcuts to save a file from insert mode are currently broken: they do not update the file modification indicator and Helix thinks the file has not been written and will not let you close it, see #6513. This shouldn't terribly change how anyone not binding to |
Looking at the changes you only add |
e2a8774
to
8adc281
Compare
Why not just stop the ability to save in insert mode? I admit when I first started using Helix I bound ctrl-s to save and saved all the time in insert mode. This was a mistake and led me down the wrong path for using Helix, if it were not possible I never would have wasted my time doing it. |
I think it's worth fixing this regardless of the use-case, although I'm not a huge fan of the saving-in-insert-mode use-case. Ideally we shouldn't have to think about making commit checkpoints in typeable commands like |
yeah I don't care for the saving in insertmode usecase that much but I do care about the sequence of commands (in normal mode) usecase |
8adc281
to
3b2691b
Compare
@the-mikedavis Feedback addressed, ready for re-review. I'll keep test driving but works well locally. |
I've been daily driving this for about a week now and it fixes a bunch of stability issues i've been having :) |
This improves the situation but I believe we need a larger change to make sure we're treating all |
@the-mikedavis any update on your end? I'll be rebasing my fork soon and would like to try out your patch, if it's finished. (though imo i think this should just be merged as-is and improved later...) |
I pushed up the change here: https://github.com/helix-editor/helix/tree/append-changes-ensure-cursor-automatically I made a few more changes before I pushed it so I'll try it out for a while before I turn it into a PR |
Fixes #6513, fixes #3501, addresses #1583. This somewhat changes the granularity of the undo history: but keeps the preciseness. While adding to the undo history on a save may not seem idiomatic conceptually at first: I think it's the best way to address the issue, because 1) saving a file is somewhat of a "finishing" action and 2) comparing the undo history with the current state of a file is quite a nice way to check if something has been modified and I would prefer not to mess with it.
I also added e2a8774 because I stumbled across it while tracking down this issue and thought that having a separate history entry for a raw paste before any manipulation of it would be desirable. I'd be fine rolling it back but that also propagating to history makes more sense to me.