AutoFoldCode icon indicating copy to clipboard operation
AutoFoldCode copied to clipboard

Prevents focus on new files

Open dwhenson opened this issue 4 years ago • 2 comments

When I create a new file (using file manager package) the package prevents focus remaining on the new file itself and I have to click back to refocus the cursor on the page. I tried removing quite a few plugins before identifying this one as the cause

dwhenson avatar Sep 13 '21 07:09 dwhenson

Yes. I independently confirmed this before ever arriving here. It was impeding AdvancedNewFile's new files from being focused on.

Unknow0059 avatar May 21 '24 02:05 Unknow0059

This is related to AutoFoldCode (AFC)'s saving and restoring of selections into and from settings.


Regarding saving,

selections are saved on close: https://github.com/Vasily-X/AutoFoldCode/blob/47d1a7e64f560a5b3b3abb79ceb7912bf2605cab/AutoFoldCode.py#L175-L178 ... even zero-width empty selections with a hash of 0x0.

It also seems ST's save_settings() autosaves to a User version of the settings.

This doesn't cause the issue, but it's useless.

Regarding restoring,

Due to on_load_async(), L116's codeblock runs when a new file is made: https://github.com/Vasily-X/AutoFoldCode/blob/47d1a7e64f560a5b3b3abb79ceb7912bf2605cab/AutoFoldCode.py#L134-L137

We see that L137 clears the current selection.

By Default, AFC.sublime-settings' selections value is empty, so L139 adds nothing.

It seems __storage_file__ is loaded from, which ST does not autoresolve to User (nor should it).

Meanwhile, __storage_path__ is a variable that exists and points to User settings, and is not used anywhere.

Problem

  • _load_storage_settings() always loads from Default, when it should be loading conditionally. It needs to be rewritten to accommodate.

Workarounds:

  • Disable "save_selections" in AFC.sublime-settings by setting it to false.
  • Comment L137 or L90 out.

Unknow0059 avatar May 21 '24 09:05 Unknow0059