sublime_text icon indicating copy to clipboard operation
sublime_text copied to clipboard

Automatically create "anonymous" .sublime-project files when closing a window (not already saved in a .sublime-project)

Open evandrocoan opened this issue 5 years ago • 4 comments

Problem description

When you open Sublime Text with subl /some/full/path/directory and you close Sublime Text without saving it in a .sublime-project file, all your workspace and the open directory itself are lost when you close the "anonymous project" window (a Sublime Text window with open directories not saved in a .sublime-project file could be called a "anonymous" project).

Preferred solution

After you open Sublime Text with subl /some/full/path/directory and you close that window without saving first a .sublime-project file, Sublime Text automatically creates an "anonymous" project in his Data/cache/anonymousprojects directory, with the base name of the first directory opened on the recent-closed window, i.e., directory.sublime-project. If the file already exists, then it includes a timestamp on the directory name. Then, this "anonymous" project (and workspace) could be reopened later on, by going to the menu Project -> Open Recent -> directory.sublime-project

Additionally, a new command should also be added, the Renamed Project File, which would change the name of the project file in the Data/cache/anonymousprojects directory or any other place the .sublime-project file is on. This command would be useful to properly name my "anonymous" projects which do no get a nice name when automatically created, i.e., directory-2019-12-15.sublime-project

Related issues

  1. .sublime-project file without the file name part #828
  2. Layout not saving on Sublime Text 3 quit #1907

evandrocoan avatar Dec 16 '19 01:12 evandrocoan

Sounds like an idea for a plugin or maybe an extension for @ranky3k's ProjectManager.

A plugin an query window.project_file_name() and the window.project_data() with the folders being added. An EventListener could be used to check those and automatically save an auto-generated project. As the save_project_as doesn't take a file argument to silently save the project, you'd probably need to manually encode and write the JSON data.

A normal quick panel or better a command with InputHandler could be used to open the most recent auto-generated projects.

deathaxe avatar Dec 16 '19 10:12 deathaxe

This might be one of possible implementations of the following feature request: https://forum.sublimetext.com/t/open-recent-reopen-closed-window/37802

d0vgan avatar Jan 02 '20 12:01 d0vgan

This would really be helpful if implemented. Like, when we close an anonymous file, we always get prompted whether to save it or not. With an anonymous project, it should act the same.

davidhcefx avatar Dec 24 '21 14:12 davidhcefx

FYI just found this plugin which is almost what is being discussed here - though still not the most invisible solution.

https://github.com/jmooney/EasyWorkspace-sublime

Semmu avatar Sep 19 '22 12:09 Semmu