Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load the file history asynchronously and keep the quick panel open #47

Open
evandrocoan opened this issue Sep 16, 2018 · 8 comments
Open
Labels

Comments

@evandrocoan
Copy link

My files history is big so when I ask for the history Sublime Text free like for 20 seconds.
I like the history big, then I prefer to wait, but while waiting:

  1. Keep Sublime Text UI frozen is not nice.
  2. When I came back to the Sublime Text window, Sublime Text is unfrozen, but no quick panel open (perhaps KEEP_OPEN_ON_FOCUS_LOST is not set?).

image

@FichteFoll
Copy link
Owner

How big is your history? Do you happen to have remove_non_existent_files_on_preview enabled? Do you have cleanup_on_startup enabled? (Just post your entire settings.) Which command makes ST freeze exactly?

@evandrocoan
Copy link
Author

evandrocoan commented Sep 16, 2018

The command selected in the picture freezes Sublime Text. My history file has ~300 KB in size.

These is my settings file:

{
    // Path to store the history entries in (relative to the sublime packages
    // path).
    "history_file": "User/FileHistory.json",

    // Maximum number of history entries we should keep (older entries
    // truncated).
    "global_max_entries": 1000,

    // Maximum number of history entries we should keep (older entries
    // truncated).
    "project_max_entries": 500,

    // Try to use the saved position of the file or blindly use the
    // "new_tab_position" setting.
    "use_saved_position": true,

    // Which position to open a file at when the saved index in no longer
    // valid.
    //
    // Options: "next", "first", "last"
    "new_tab_position": "next",

    // Should we show a preview of the history entries?
    "show_file_preview": true,

    // Re-open a file in the current group if it is already open in another one?
    "reopen_file_in_current_group": false,

    // Remove any non-existent files from the history (when previewed or
    // opened).
    "remove_non_existent_files_on_preview": false,

    // If a cleanup of the history should be run on startup.
    "cleanup_on_startup": true,

    // Should the history be reset on startup?
    //
    // BE CAREFUL, this will DELETE ALL of your history entries.
    "delete_all_on_startup": false,

    // Should a monospace font be used in the quick panel?
    "monospace_font": false,

    // Should the last accessed timestamp be shown in the quick panel?
    "timestamp_show": true,

    // Whether timestamps should be a relative approximation
    // e.g. '2 days, 5 hours', or an absolute timestamp using
    // the format below.
    "timestamp_relative": true,

    // Format of the absolute timestamp that should be added to the history
    // entry.
    "timestamp_format": "%Y-%m-%d @ %H:%M:%S",

    // Which timestamp to display?
    // "history_access" - last opened/closed timestamp
    // "filesystem"     - the file's last modified timestamp
    "timestamp_mode": "history_access",

    // Should the history file be nicely formatted?
    "prettify_history": false,

    // List of path regexs to exclude from the history tracking.
    // Can be extended in project settings (in a "file_histoy" dict).
    //
    // Note: You must use forward slashes for the path separator (regardless of
    // platform) and escape backslashes properly.
    //
    // Example: ["/temp/", "C:/Program Files/Internet Explorer/", "\\.bak$"]
    "path_exclude_patterns": [],

    // List of path regexs that will re-include files that were excluded before.
    // Can be extended in project settings (in a "file_histoy" dict).
    //
    // Note: You must use forward slashes for the path separator (regardless of
    // platform) and escape backslashes properly.
    //
    // Example: ["C:/Program Files/Internet Explorer/subdir/", "\\.my\\.bak$"]
    "path_reinclude_patterns": [],

    // The number of daily backups to keep (backup is saved the first time the
    // history is modified).
    //
    // To turn off backups, change this setting to 0 (zero).
    "max_backup_count": 3,

    // Print out debug text?
    "debug": false
}


@FichteFoll
Copy link
Owner

Okay, so that's basically default with the limits increased.

I haven't been in touch with this code base in a while, but I don't recall a lot of "things" happening in order to display the popup. There shouldn't be a reason to access the file system and loading a couple hundred dicts in memory is no issue nowadays.

The history file is loaded on startup synchronously (although it should certainly be asynchronously, but I haven't bothered to change that yet as it is still fast enough), so it's also not re-loaded whenever the popup is requested.

@evandrocoan
Copy link
Author

evandrocoan commented Sep 16, 2018

That is strange then. Makes no sense why Sublime Text is hanging when I use the command. Indeed, while Sublime Text is hanged, 0% of the CPU is used.

I just noticed, this does not happens to all projects. If I am on a window with no project, it does not happen. On a project which this does happens, you can see Sublime Text CPU drops from 0.2 to 0.03 after I issue the command. And only restores back to normality when the command finishes.

@evandrocoan
Copy link
Author

evandrocoan commented Mar 2, 2019

*I tested today. This issue (Original Post) does not happens on Linux, i..e, Windows only.

evandrocoan added a commit to evandroforks/FileHistory that referenced this issue Mar 2, 2019
Load the file history asynchronously and keep the quick panel open
FichteFoll#47
@evandrocoan
Copy link
Author

Now, after adding sublime.KEEP_OPEN_ON_FOCUS_LOST, neither I can reproduce this on Windows. I will wait until the next time this happens, and I am going narrow it down (debug it, and fix it).

@FichteFoll FichteFoll added the bug label Aug 26, 2019
@evandrocoan
Copy link
Author

I think I figure out the problem. I just manage to reproduce it on Windows. This only happens the first time I use this plugin because it is building the file history list. The fix would not be to hang the UI when it is building the history list cache, or just not build any list at all.

Things like os.path.dirname(filepath) and os.path.exists(filepath) are querying my hard disk, meaning they will take some time if I am not using an SSD and there is a big number of files to query.

@FichteFoll
Copy link
Owner

Thanks for figuring that out. I assume doing the initial load on startup asynchronously, which is on the list anyway, will then get rid of the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants