GhostText icon indicating copy to clipboard operation
GhostText copied to clipboard

Sublime Text echoes the same received text

Open fregante opened this issue 4 years ago • 6 comments

This happens in any field in any browser. ST responds with the same data as soon as you type something in the browser

https://ghosttext.github.io/GhostText/demo/

This issue is currently avoided by ignoring any updates from the editor when the browser is focused, but it should still be fixed in Sublime Text.

fregante avatar Jan 27 '21 17:01 fregante

GhostText.py

+do_not_respond = False

...

     def on_message(self, text):
+    global do_not_respond
+    do_not_respond = True
         try:
             request = json.loads(text)
             self._current_view.run_command('replace_content', request)
             self._current_view.window().focus_view(self._current_view)
         except ValueError as e:
             Utils.show_error(e, 'Invalid JSON')
+        finally:
+             do_not_respond = False
....

GhostTextTools/OnSelectionModifiedListener.py

...

     def on_selection_modified(self, view):
         if view.id() not in OnSelectionModifiedListener._bind_views:
             return
+        global do_not_respond
+        if do_not_respond:
+            return

...

It should™ solve the issue

subnut avatar Jan 28 '21 04:01 subnut

I will™ try it once the stores accept the latest version

fregante avatar Jan 28 '21 05:01 fregante

Can you open a PR on https://github.com/GhostText/GhostText-for-SublimeText?

fregante avatar Jan 29 '21 05:01 fregante

I tried it, it doesn't work :disappointed:

subnut avatar Feb 23 '21 18:02 subnut

Can you please grant me push access to that repo? I will do my changes in a new branch. If the code seems OK, and I am able to understand how sublime plugins work, I will take up the responsibility of maintaining that plugin.

subnut avatar Feb 23 '21 18:02 subnut

You can submit a regular PR and merge it once it works

fregante avatar Feb 23 '21 18:02 fregante

I made a PR ☝️ https://github.com/GhostText/GhostText-for-SublimeText/pull/2 👈

kaste avatar Feb 17 '23 23:02 kaste

Confirmed to be fixed in v1.0.15

Thanks @kaste!

fregante avatar Feb 18 '23 10:02 fregante