Sublime Forum

Finally decided to use save on focus lost but it's not what I expected

#1

I’ve always been afraid to use this feature for some reason. But I forget to save enough times and wonder why my changes didn’t make a difference, I thought I’d turn it on.

But now I’ve noticed that focus is lost when I open a panel to select another file. So I haven’t left the app at all, or the current window in the app, but it’s performing a save.

That wouldn’t be bad except I think it triggers other things that are disruptive, perhaps in my very own plugin, which causes “bad things” to happen while my fingers are in auto pilot.

Does this seem weird?

I am pretty sure my plugin is the cause of this issue, as it tries to do things when the focus is lost that causes on of my quick panels to dismiss itself immediately.

But every time I switch tabs it saves … Is there an option to save all when the application window loses focus?

0 Likes

#2

I don’t use this setting myself, but the comment in the default settings says:

    // Set to true to automatically save files when switching to a different file
    // or application
    "save_on_focus_lost": false,

So I think it’s expected that it would trigger a save even without leaving the application. I’m not aware of any setting that would trigger the save only when the application loses the focus, though.

If I remember correctly, the on_deactivated event only triggers when a file loses the focus to another file, but not when Sublime loses the focus to another application. So short of something with native code that can determine what application is in the foreground, I don’t think something like this is possible via a plugin either.

0 Likes

#3

Thanks. Should have paid more attention to the comment!

Since it’s every file change I am not interested, but I suppose I should try to fix the bug in my plugin in case anyone else cares.

Cheers

0 Likes