PlainTasks icon indicating copy to clipboard operation
PlainTasks copied to clipboard

Go to file (ctrl + o) crashes Sublime Text

Open chishaku opened this issue 8 years ago • 8 comments

Go to file (ctrl + o) crashes Sublime Text

OSX 10.9.5 Sublime Text Build 3065 & 3103

I've tried for all methods of link formatting and for files that do and do not exist and Sublime crashes every time.

I tried an OSX 10.10 machine and I didn't have the issue. I'm wondering if there's anything I can do without having to upgrade my OS.

Otherwise, thanks to all contributors for the great software. I'm an old user of TaskPaper so being able to bring the same workflow to Sublime has been great.

chishaku avatar Apr 12 '16 14:04 chishaku

Sublime Text Build 3065 & 3103

3065 is outdated, current versions are 3103 & 3111.

anything I can do without having to upgrade my OS.

You can try to replicate crash on clean profile (do not forget to backup precious stuff if any) to be sure that no other plugins intervene.

If crash remains, you can try to debug using print() and return to figure out which statement in code is to blame; start from show_panel_or_open method. return is for stopping execution of following code.

OSX 10.10 machine and I didn't have the issue

FWIW, I’ve only Win8, no issue either.

If you’ll find out something or any questions, please write back.

vovkkk avatar Apr 13 '16 07:04 vovkkk

@vovkkk Thanks for the quick response.

In the show_panel_or_open method, all directories and files available in win.folders() and win.views() are walked through to resolve the full path of the target file.

In my sublime projects (and on my slow work machine), it appears that sublime crashes due to the really large number of files that need to be checked.

Lines 560-567:

fn = fn.replace('/', os.sep)
all_folders = win.folders() + [os.path.dirname(v.file_name()) for v in win.views() if v.file_name()]
for folder in set(all_folders):
    for root, _, _ in os.walk(folder):
        name = os.path.abspath(os.path.join(root, fn))
        if os.path.isfile(name):
            self._current_res.append((name, line or 0, col or 0, "f"))
        if os.path.isdir(name):
            self._current_res.append((name, 0, 0, "d"))

I replaced the above with the below to manually parse and resolve the full path and also expand any environment variables so that I can use those in my file links. The code isn't pristine but it works.

fn = fn.replace('/', os.sep)
fn = os.path.expandvars(fn)
base_folder = os.path.dirname(self.view.file_name())
if not os.path.isabs(fn):
    if fn.count('../') == 1:
        fn = fn.replace('../', '')
        base_folder = os.path.dirname(base_folder)
    elif fn.count('../') == 2:
        fn = fn.replace('../', '')
        base_folder = os.path.dirname(os.path.dirname(base_folder))
    elif fn.count('../') == 3:
        fn = fn.replace('../', '')
        base_folder = os.path.dirname(os.path.dirname(os.path.dirname(base_folder)))
    else:
        pass
    fn = os.path.join(base_folder, fn) 
print('Resolved file:', fn)

EDIT: changed the way I resolve the base_folder from base_folder = win.folders()[0].

chishaku avatar Apr 13 '16 17:04 chishaku

Hm, strange.

the really large number of files that need to be checked.

How many? Some time ago I timed Python os.path functions with big folder with more than dozen thousand of files and subfolders on kinda slow machine, it was relatively fast, like 2-5 seconds.

vovkkk avatar Apr 13 '16 19:04 vovkkk

I'm not sure but there are 13 repos loaded in the sublime-project. Maybe not ten thousand, but probably thousands.

It could certainly just be my slow machine which is already laggy in almost every other respect.

Just to be clear, it's the call to os.walk on line 563 that locks up before hitting a return call that I added on the next line.

chishaku avatar Apr 13 '16 19:04 chishaku

May be your hard-drive is about to collapse?

I’ve tested on 6 yo machine, normal SATA HDD 7200RPM.

2000 directories are walked in ≈ 2 seconds. 29000 — ≈ 33 seconds.

2016-04-14_13-57-40

2016-04-14_14-06-23

Well, I don’t know how to deal with that. I mean, we cannot take the code which works for you, because it breaks support for relative path in file link. But if this code is good enough for your needs then you should copy the entire command (i.e. class) and save it in separate file at Packages/User, rename command to something unique, e.g. MyVeryOwnPlainTasksOpenLinkCommand, and rebind keys to this new command in user keybinding files. So if we make some update, your changes will be safe.

vovkkk avatar Apr 14 '16 08:04 vovkkk

I will do that. Thank you for the advice and your responsiveness.

chishaku avatar Apr 14 '16 15:04 chishaku

I'm having the same problem in Sublime 3103, Debian Linux 8

uscmule avatar Apr 26 '16 19:04 uscmule

I’ve same result on Ubuntu 14.04 as on Windows 8.1 above, btw machine with Ubuntu even slightly slower (I mean cpu & hdd specs) than Windows one

2016-04-27

No idea what may cause crash, probably hardware, or filesystem driver, I dunno.

vovkkk avatar Apr 27 '16 12:04 vovkkk