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

Remove dead projects from the recent list #1793

Closed
dufferzafar opened this issue Jul 1, 2017 · 11 comments
Closed

Remove dead projects from the recent list #1793

dufferzafar opened this issue Jul 1, 2017 · 11 comments

Comments

@dufferzafar
Copy link

I moved a project to a different location but that change does not reflect in the Switch Project screen. It still tries to load it from the original directory & fails, but the entry stays in the list.

Re-opening the project in Sublime adds duplicates in the Switch Project list.

The only current option is to Clear recent projects and re-add all projects, which is just too much work.

Projects that can't be opened should be removed from that list.

@evandrocoan
Copy link

evandrocoan commented Jul 1, 2017

You could write a program/package for Sublime Text which reads the recent_workspaces list, and removes the entries which are missing. So there is not need for the Sublime Text core to perform these tasks.

@dufferzafar
Copy link
Author

@evandrocoan Yes, that seems like a good enough workaround. This could even be done outside of sublime as a simple Python script. BTW, Can sublime packages even modify recent_workspaces?

@evandrocoan
Copy link

Probably yes. You should test to know for sure. Just take care to handle both files:

  1. Session.sublime_session
  2. Auto Save Session.sublime_session

You could do this every time you open Sublime Text on plugin_loaded() forward, or when the command switch_project is issued:

import sublime
import sublime_plugin


def clean_recent_workspace():
    print( "Cleaning clean recent workspace" )


class SampleListener( sublime_plugin.EventListener ):

    def on_window_command( self, window, command_name, args ):
        print( "About to execute " + command_name )

        if command_name in ( 'prompt_select_workspace', 'open_recent_project_or_workspace' ):
            
            # run it on an alternate thread to not hang Sublime Text
            sublime.set_timeout( clean_recent_workspace, 1000 )

@evandrocoan
Copy link

But I do not know whether it will work when Sublime Text is opened due the Auto Save Session.sublime_session file, which could be constantly overridden by Sublime Text. Therefore your changes could be lost.

@keith-hall
Copy link
Collaborator

(personal opinion) I don't really think it's a good idea to encourage plugins to mess with the session/auto-save files. Anyway, this is a duplicate of #88

@evandrocoan
Copy link

evandrocoan commented Jul 3, 2017

I just tried to edit the Session.sublime_session while Sublime Text was open, but was a completely failure. Sublime Text keeps ignoring my changes to it and overriding them. The only way to successfully edit it, is when Sublime Text is closed.

@dufferzafar
Copy link
Author

Since this can not be done via a package, this has to be fixed in Core. Sadly, the last comment on #88 is more than 2 years old. Maybe not a lot of people are affected by this.

@evandrocoan
Copy link

evandrocoan commented Jul 3, 2017

Well, this is something does not happens often, then when it does, I close Sublime Text, open the session file, fix the bad entries, and open Sublime Text again.

You could write a python script, which cleans the session file and opens Sublime Text after it.

You could also upvote it:

image

@dufferzafar
Copy link
Author

I wrote such a script some time back and it works just fine: https://github.com/dufferzafar/.scripts/blob/master/sublime_session_fix

@OdatNurd
Copy link

OdatNurd commented Sep 21, 2018

You may also be interested in this script as well; it automatically detects your data directory regardless of platform (unless you're using a portable install, in which case you have to use the command line parameter), supports a dry run mode so you can verify what it's going to do, and keeps backups just in case.

It supports both Sublime Text and Sublime Merge (select which app to use via the command line).

@dufferzafar
Copy link
Author

@OdatNurd Thanks for that one. I'll use it from now on. It certainly is way better than mine.

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

No branches or pull requests

4 participants