jlebon / textern

A Firefox add-on for editing text in your favourite external editor!
GNU General Public License v3.0
141 stars 21 forks source link

browser.notifications is undefined #41

Open diamond-lizard opened 6 years ago

diamond-lizard commented 6 years ago

I just installed the textern extension and did:

git clone --recurse-submodules https://github.com/jlebon/textern
cd textern
make native-install USER=1

I changed textern's "External editor" option to:

["/home/me/bin/emacs-in-new-xterm", "%s", "%l", "%c"]

and the shortcut to:

Ctrl+Shift+E

Then I restarted Firefox, and in a text form I typed Ctrl+Shift+E which only resulted in the letter "e" being typed in to the text form.

No editor started up, but Firefox showed this error:

JavaScript error: moz-extension://a4a4e86d-25ed-4f9b-adef-68194c24eda4/content.js, line 20: TypeError: browser.notifications is undefined

I am on Firefox 60.3.0esr (64-bit) on Gentoo Linux.

diamond-lizard commented 6 years ago

I don't know why, but if I wrap the code inside the with clause in textern.py's main() inside a try ... except, it works (in some places, at least). Here's the code:

def main():
    with INotify() as ino, TmpManager() as tmp_mgr:
        try:
            ino.add_watch(tmp_mgr.tmpdir, flags.CLOSE_WRITE)
            loop = asyncio.get_event_loop()
            loop.add_reader(sys.stdin.buffer, handle_stdin, tmp_mgr)
            loop.add_reader(ino.fd, handle_inotify_event, ino, tmp_mgr)
            loop.run_forever()
            loop.close()
        except Exception as e:
            raise e

Without this change, the behavior is as I described in my original issue report above. With the change, I've tested that this works here in this GitHub issue report text form, and in a text form on the old Reddit https://old.reddit.com/r/firefox/submit

But it still doesn't work in the new Reddit: https://www.reddit.com/r/firefox/submit

There it just prints "e" inside the text form when I hit Ctrl+Shift+e. It's as if it's not even recognizing that I'm sending the keystroke.