lite-xl-plugins icon indicating copy to clipboard operation
lite-xl-plugins copied to clipboard

Autosave bug

Open ravaq opened this issue 1 year ago • 8 comments

Hi (should I post this here or in the plugins page?)

  1. for me, 'autosaveonfocuslost' plugin doesn't work.
  2. 'autosave' plugin works, but if change focus before autosaving, it doesn't autosave anymore until another change in the code, even after refocus on tab.

ravaq avatar Aug 15 '23 09:08 ravaq

Hi (should I post this here or in the plugins page?)

Yep, makes more sense for this to be there. I'll transfer this.

  1. for me, 'autosaveonfocuslost' plugin doesn't work.
  2. 'autosave' plugin works, but if change focus before autosaving, it doesn't autosave anymore until another change in the code, even after refocus on tab.

I'll give a look.

Guldoman avatar Aug 15 '23 19:08 Guldoman

  1. for me, 'autosaveonfocuslost' plugin doesn't work.

Mmm, seems to work for me. What are your steps? Keep in mind that it's only saving the currently open and visible document. We could make it save everything tho.

  1. 'autosave' plugin works, but if change focus before autosaving, it doesn't autosave anymore until another change in the code, even after refocus on tab.

This plugin is a bit weird as it simply runs the save command (as if you were pressing ctrl+s, so targeted to the currently opened and visible file) after a timeout from the last change in any opened doc. So if you change tab before the timeout, it'll save the new selected tab. Yeah, we need to make this one more robust too...

For the focus issue with autosave, this is an issue of Lite XL, as we try not to run anything while we're not in focus. We have a couple of ideas to remedy that, but the issue is still there.

Guldoman avatar Aug 15 '23 20:08 Guldoman

Thanks

  1. I don't understand, do you mean my steps for unfocusing the tab? just by changing the tab or clicking on the left pane items and so on.
  2. The problem is that even when the tab returns to focus, the autosave doesn't work until the next change, as if it forgot that the tab remained unsaved. perhaps each tab could have some 'unsaved flag' so that the autosave plugin saves tabs with this flag when focus is lost or refocused or the app is closed. And it would have been better to have the option to save unsaved tabs when closing the tab or application, instead of the confirmation dialog for closing unsaved tabs.

ravaq avatar Aug 16 '23 06:08 ravaq

  1. I don't understand, do you mean my steps for unfocusing the tab? just by changing the tab or clicking on the left pane items and so on.

The focus the plugin works on, is the window focus, not the tab focus. I guess it could be improved to handle that too...

  1. The problem is that even when the tab returns to focus, the autosave doesn't work until the next change, as if it forgot that the tab remained unsaved. perhaps each tab could have some 'unsaved flag' so that the autosave plugin saves tabs with this flag when focus is lost or refocused or the app is closed.

It's because the save command was sent to the tab that was selected when the timeout expired. So yeah, it's just that the plugin should keep track of which doc to save.

And it would have been better to have the option to save unsaved tabs when closing the tab or application, instead of the confirmation dialog for closing unsaved tabs.

Yeah I guess that could be improved. If you open an issue about it in the main repo, we'll keep track of that.

Guldoman avatar Aug 16 '23 16:08 Guldoman

The focus the plugin works on, is the window focus, not the tab focus. I guess it could be improved to handle that too...

ok, sorry, I misunderstood, and it's clear in the plugin description.

Yeah I guess that could be improved. If you open an issue about it in the main repo, we'll keep track of that.

thanks again, and can you re-transfer it? :)

ravaq avatar Aug 17 '23 04:08 ravaq

ok, sorry, I misunderstood, and it's clear in the plugin description.

No worries. The idea of saving on tab change could be implemented too.

Yeah I guess that could be improved. If you open an issue about it in the main repo, we'll keep track of that.

thanks again, and can you re-transfer it? :)

Might be better to create a new issue about it to avoid confusion, and to keep this here as a feature request about autosaveonfocuslost as well as bug report about autosave.

Guldoman avatar Aug 17 '23 13:08 Guldoman

Hi. autosaveonfocuslost doesn't work for me, even if I change window focus.

I'm running on Hyprland wm.

BartolomeyKant avatar Jul 15 '24 07:07 BartolomeyKant

It's possible that Hyprland doesn't let the window know that it lost focus. Try running Lite XL in full Wayland mode like this: SDL_VIDEODRIVER=wayland lite-xl.

Guldoman avatar Jul 19 '24 20:07 Guldoman