FichteFoll / InsertDate

Sublime Text Plugin that provides a configurable command and popup for inserting the current date and time (with specific format)
MIT License
124 stars 18 forks source link

Set read only to preserve whitespaces on autosave #26

Closed vovkkk closed 9 years ago

vovkkk commented 9 years ago

ST has two [arguably] useful features, which are disabled by default, iirc:

  1. Autosave file on lost focus.
  2. Trim trailing whitespaces on save.

The issue is that quick panel is counted as lost focus.

FichteFoll commented 9 years ago

So you mean if you have "autosave on focus lost" enabled, ST trims trailing whitespace on save because it thinks it lost focus? That's bothersome. I'll check for this and report it on https://github.com/SublimeTextIssues/Core.

The way you implemented this is problematic however, because it will remove the read_only state even if only the insert_date command was called. I'll implement this differently, but thanks for the heads up.

vovkkk commented 9 years ago

Yes, in many cases when you got cursor outside of previously active view (quick panel, console, go to anything, search, etc.), then it considers a focus is lost. Those settings are "save_on_focus_lost": true & "trim_automatic_white_space": true.

vovkkk commented 9 years ago

Oops, those are "save_on_focus_lost": true & "trim_trailing_white_space_on_save": true.

BTW, generally speaking, especially as a person who uses and appreciates both features/settings, I’d say that it is good, rather than bad, again generally speaking; because more saves is good thing in absence of proper autosave.

But yea, perhaps it should make exception for quick panel, since it is kind of basic way to offer custom input for 3rd party plugins. FWIW, ST3 has show_popup_menu which keep focus in the view, but it’s not available in ST2.

FichteFoll commented 9 years ago

show_popup_menu isn't really suited as well as a quick panel for this task though.

FichteFoll commented 9 years ago

I think I found a good way to work around this issue, which I reported at https://github.com/SublimeTextIssues/Core/issues/980 btw.

Will push a new release once I figured out how I can solve #25.