Sublime Forum

Preventing a save in "on_pre_save"

#1

I’m writing a simple Perforce plugin that lets me easily checkout a file from my active Perforce client.

The checkout command works fine, but what I’d like to do now is create an on_pre_save event that looks to see if the file needs to be checked out, pops up a box asking if I’d like to check it out, and does so if I answer yes.

The problem is when I answer no – is there some way to cancel the save action from within an on_pre_save event?

0 Likes

#2

Question…how far did you get with this plugin? Does it work with Sublime Text 2? Do you need any help? Would like to use it.

–George

0 Likes

#3

Delayed reaction!

I got as far as I needed for my purposes – essentially when you save, it tries to do a checkout if necessary, and then saves.

What it does not do is prompt the user for confirmation or give you the chance to log in. I wasn’t too happy with the input options ST2 offered (at the time anyway; haven’t explored it since then), so I made myself content with it just using the system credentials if I was already logged in.

The downside is that if my credentials have expired, it just fails to save, but it’s easy enough to pop over to the GUI client (or command line) and refresh them.

0 Likes