pulsar-edit / pulsar

A Community-led Hyper-Hackable Text Editor
https://pulsar-edit.dev
Other
3.36k stars 141 forks source link

[autosave] Add settings for more granular behavior #1140

Open NormPlum opened 1 week ago

NormPlum commented 1 week ago

Have you checked for existing feature requests?

Summary

The Autosave package has a single setting: the Enabled toggle. This enables automatically saving the editor when it loses focus, is destroyed, or the window is closed.

This isn't very flexible, so I'd like to propose adding additional settings:

(or any combination thereof)

What benefits does this feature provide?

This would allow you to choose when the editor is autosaved.

My use case is that I have the Whitespace package installed, which is set to remove all trailing whitespace on save. With Autosave also enabled, this means when I have my cursor indented on a new line ready to add code, and then I alt-tab away to look something up, when I come back the editor has been saved, the whitespace is removed, and my cursor is no longer indented.

So being able to choose exactly when the editor is autosaved would be really handy. In my case I'd have it autosave on destory and when the window's closed, but not when it loses focus.

Any alternatives?

I think adding additional settings here makes more sense, rather than in another (community) package.

Other examples:

No response

savetheclocktower commented 1 week ago

The good news is that there's a setting in the whitespace package that will prevent this outcome: make sure to check Ignore Whitespace On Current Line if you want to prevent autosave from dedenting your cursor in these scenarios.

(I was worried it was failing to treat the current line as the current line in a situation where focus was lost, but I just tried this out, and it worked the way I hoped.)

In the meantime, this is a fair feature request even if there's a workaround for your scenario, so I'll leave this open. Thanks for the report!

NormPlum commented 1 week ago

Thanks @savetheclocktower. Yeah, I saw that option in the Whitespace settings, but I've had trouble in the past when my cursor's on a line with trailing whitespace and I save and close Pulsar, then the whitespace remains (when it should be removed).