-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Autosave locally #3342
Comments
Enabling autosave works fine for me both from command line and settings.json. Can you provide more information ( |
2.0.14-dev.201 No need to quote my statement. I am not talking about global autosave, which works fine if toggled with settings.json, but still doesn't work from prompt. If you look closely, I am talking about local setting. |
I see the issue now: Lines 421 to 424 in 650c0a8
I can think of a few ways of fixing this:
This part I still can't reproduce though. How did you figure out it's not working? |
I believe option 3 is the right way. And yes, I don't see the logic in autosave on every change that was made, autosave on exit sounds more logical, when we already have backups.
Strange question, It doesn't auto save : ) I would be happy with the variable option only available, I need autosave only for CLI messaging apps anyway. Screen.Recording.2024-06-13.at.08.59.16.mov |
That's very strange. I can see, that it isn't working for you, but currently I can't reproduce it in that way under Linux. micro/internal/config/settings.go Lines 175 to 185 in 55f45ce
Anyway I tested it with it being set to |
Nope, as I said before, I don't need global autosave. Yes, it is strange. I found which setting in init.lua was causing dysfunctional autosave variable. Still can't imagine why this function is overriding the variable at start.
|
Aaah, ok...now it becomes clear: micro/internal/buffer/settings.go Lines 22 to 33 in 650c0a8
The call to |
Feel free to apply the patch from the linked PR and test if it now fits to your expectation. |
Thanks |
But still, autosave on exit would be better, I believe. |
It does exactly that in the moment micro/internal/action/actions.go Lines 1645 to 1649 in 55f45ce
|
Tested, nothing has changed. Variable still doesn't work if you change the file type for buffer in init.lua |
|
Why not?
That means that 1 second would be the minimum granularity, which is a limitation of functionality.
Because saving the file after inserting or removing every single character is a big overkill. |
If all you need is autosave on exit, you can use something like this in
...And you can make it customizable per buffer, e.g. with:
You can then use e.g.:
Note: if you also want to be able to change this |
All that said, we may consider adding support for a special value for the |
Thank you. I knew there must be a simple function for that. But how it can be changed, so it autosaves not by file type, but only at certain file/files? Tried this one with no luck:
Update: Nevermind, instead of partial name, I have set it to the full path with name and it works! Thank you again. |
Constantly having a bunch of timers running & saving potentially dozens of files most of which aren't modified seems pretty wasteful. The timer behavior is also just weird: if you have a 10 second timer the save might happen either instantly after a change or 10 seconds after a change.
I struggle to think of a use case for more granularity. The current minimum granularity is 1 second and I haven't seen any complaints about it: micro/internal/config/autosave.go Line 40 in 650c0a8
It would still be debounced with a short timer. This is generally how other editors do it, and how I (and probably most users?) would expect autosave to work. |
If micro is saving a file every time without even checking if it was modified, that is already a huge waste. And that is what is actually happening (as I've just found), lol.
Indeed. I thought it was a floating-point number.
Ok, I have no strong opinion what is better, a debounce timer or a periodic timer. I don't use autosave myself, so I don't know what would a user expect. (I suppose most micro users don't users don't use it either, which is why no one has complained/noticed that it is needlessly saving an unmodified file in the background all the time, for example.) Still, if I wanted to use it, I imagine I wouldn't care how many seconds after a change would the save happen, - for the same reason that I wouldn't like it to happen after every change. I would just want it to happen from time to time (and probably would prefer to be able to configure how often it happens). So it isn't obvious to me what are the merits of using a debounce timer instead. |
Quick fix: #3356 |
We converted the user input from Adding a timer per buffer sounds a bit too much to me. From my perspective the "ticker" idea sounds like a good compromise to have it somehow specific per buffer, but still with one general timer of what ever granularity. The save shall then take place every time the tick count has been consumed, while it's reset after every change and save. |
@Bellavene |
The tutorial and help options state this:
But it doesn't work with autosave option, starting micro with
micro -autosave 1
doesn't work either... I see that this isn't working at least 4-5 years, why?The text was updated successfully, but these errors were encountered: