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

OnBeforeSave result ignored #3

Open
clach04 opened this issue Mar 14, 2023 · 3 comments
Open

OnBeforeSave result ignored #3

clach04 opened this issue Mar 14, 2023 · 3 comments

Comments

@clach04
Copy link

clach04 commented Mar 14, 2023

I experimented with the OnBeforeSave event, which https://www.scintilla.org/SciTEExtension.html documents as:

OnBeforeSave is called before saving the file and an extension may implement file saving itself and return true to prevent the default file save code from executing.

I've tried returning True (and even 1, False, and 0 for completeness) but each time the file is saved to disk:

def OnBeforeSave(filename):
        print('plugin %s file %s' % (__file__, filename))  # goes to output pane
        #return True
        #return False
        return 1
        #return 0

The event does fire as output is displayed to the output pane, i.e. the register is successful.

is this a bug in scite-with-python, doc issue, bug in code above?

@benf-write
Copy link

I would try the following and see if they work,

  • Returning the special string "StopEventPropagation"
  • Or, raising an unhandled exception.

Let me know if this helps!

@clach04
Copy link
Author

clach04 commented Mar 16, 2023

@benf-write yep the magic value did it! I did not try and unhandled exception.

I guess it's deliberate based on

if (strEqual("StopEventPropagation", string))
?

This should give me enough to get encryption/decryption working with Scite and my library https://github.com/clach04/puren_tonbo (once I get a few hours to duct tape them together) :-)

Thanks again for this project and for the help!

@clach04
Copy link
Author

clach04 commented Mar 16, 2023

For completeness, working version(s):

from scite_extend_ui import ScConst

def OnBeforeSave(filename):
        print('plugin %s file %s' % (__file__, filename))  # goes to output pane
        return False  # Scite will handle save
        #return "StopEventPropagation"  # works
        #return ScConst.StopEventPropagation  # works, tells Scite to NOT save

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

No branches or pull requests

2 participants