From 1900942da2cb60a986c85bf74569f33c3665d0e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20=C5=81azarz?= Date: Fri, 21 Aug 2020 12:29:46 +0200 Subject: [PATCH] Fixed problems with exec not changing alternatives and replace not changing text in editor. --- thesaurus.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/thesaurus.py b/thesaurus.py index 57e5930..e6e7364 100644 --- a/thesaurus.py +++ b/thesaurus.py @@ -56,7 +56,7 @@ def processWord(self, word): sublime.active_window().show_quick_panel(self.alternatives, self.alternativeIsSelected) def alternativeIsSelected(self, value): - if value > 1: + if value >= 1: self.processWord(self.alternatives[value]) else: self.view.erase_status("Thesaurus") @@ -78,7 +78,7 @@ def replace(self, value): value = re.subn(r'\(.*?\)$', "", value)[0] if value is not None: - self.view.replace(self.edit, self.region, value.strip().lower()) + self.view.run_command("insert", {"characters": value.strip().lower()}) def synonyms(self): result = [] @@ -129,7 +129,9 @@ def get_alternative_words(self): p.stdout.close() alternatives = [] # this will replace the alternatives var - exec(alternativesString) + ldict = {} + exec(alternativesString, globals(), ldict) + alternatives = ldict['alternatives'] except Exception as err: alternatives = ['error', str(err)] if alternatives[0] == "error":