Menu

Bug in rereplace w/ editor.callback?

Help
2014-07-03
2014-07-15
  • Juergen Busch

    Juergen Busch - 2014-07-03

    I found a severe problem, when I tried to use editor.userListShow with editor.callback for SCINTILLANOTIFICATION.USERLISTSELECTION.

    The list shows a set of options and when I select one of the options the callback is called, identifies the selected option and calls an appropriate py-script modifying the current buffer. All py-scripts work fine, except one that uses research (used for counting the regex pattern matches) and rereplace/replace. That py-script is working well on the notepad.callback for NOTIFICATION.FILEBEFORESAVE but not editor's SCINTILLANOTIFICATION.USERLISTSELECTION callback.

    Moving the whole code from the callback function to a new py-script and trying it there, it works fine. So to me the problem is not located in the code but just in rereplace/replace. I could trace down (using console.write) that the rereplace callback delivering the replacement string works fine until it comes to the return. There Notepad++ hangs up completely.

    Am I doing something wrong? Did I miss a hint from the docs?

    I was just up to submit that post, when I realized, that another script (using re/replace, too) works fine on the file just opened when called from startup.py but fails miserably when called at runtime via PythonScript menu...

    I'm lost!

     
  • Dave Brotherstone

    I'll try and reproduce this - it's certainly feasible, as (re)search and (re)replace do switch threads when they run, and as soon as you bring a scintilla callback in the mix, you've got a third thread playing the game too.

    In the meantime, what would be really helpful, is what other (if any) notepad/editor methods are called in your callback for USERLISTSELECTION?

    Also, does making the callback synchronous (use editor.callbackSync() instead of editor.callback()) fix the issue?

    For the script that works during startup.py but fails via the menu, can you also list what notepad/editor calls you make, ideally in what order? Be great if you could post the script, but I understand if that's not possible (if you want to mail it to me so it's not public, that's fine too).

    Cheers,
    Dave.

     
  • Dave Brotherstone

    Ok, reproduced and fixed. Many thanks for the detailed error report!

    There'll be a new version shortly.

    Cheers,
    Dave.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.