AssistantEric/Assistant.py

changeset 132
eb12cd27384f
parent 131
7d868e8e1cfb
child 135
08cb4f36ad47
--- a/AssistantEric/Assistant.py	Sat Dec 03 18:08:44 2016 +0100
+++ b/AssistantEric/Assistant.py	Sun Dec 18 14:09:26 2016 +0100
@@ -311,7 +311,7 @@
         line, col = editor.getCursorPosition()
         self.__completingContext = context
         sep = ""
-        if context:
+        if language and context:
             wc = re.sub("\w", "", editor.wordCharacters())
             pat = re.compile("\w{0}".format(re.escape(wc)))
             text = editor.text(line)
@@ -361,13 +361,16 @@
         else:
             beg = editor.text(line)[:col]
         col = len(beg)
-        wsep = editor.getLexer().autoCompletionWordSeparators()
-        if wsep:
-            wsep.append(" ")
-            if col > 0 and beg[col - 1] in wsep:
+        if language:
+            wseps = editor.getLexer().autoCompletionWordSeparators()
+        else:
+            wseps = []
+        if wseps:
+            wseps.append(" ")
+            if col > 0 and beg[col - 1] in wseps:
                 col -= 1
             else:
-                while col > 0 and beg[col - 1] not in wsep:
+                while col > 0 and beg[col - 1] not in wseps:
                     col -= 1
                 if col > 0 and beg[col - 1] != " ":
                     col -= 1
@@ -399,8 +402,8 @@
                     importCompletion = True
                     prefix = tokens[1]
                     col = len(prefix) - 1
-                    wsep = editor.getLexer().autoCompletionWordSeparators()
-                    while col >= 0 and prefix[col] not in wsep:
+                    wseps = editor.getLexer().autoCompletionWordSeparators()
+                    while col >= 0 and prefix[col] not in wseps:
                         col -= 1
                     if col >= 0:
                         prefix = prefix[col + 1:]
@@ -808,12 +811,15 @@
         mod = None
         beg = editor.text(line)[:col]
         col = len(beg)
-        wsep = editor.getLexer().autoCompletionWordSeparators()
-        if wsep:
-            if col > 0 and beg[col - 1] in wsep:
+        if language:
+            wseps = editor.getLexer().autoCompletionWordSeparators()
+        else:
+            wseps = []
+        if wseps:
+            if col > 0 and beg[col - 1] in wseps:
                 col -= 1
             else:
-                while col > 0 and beg[col - 1] not in wsep + [" ", "\t"]:
+                while col > 0 and beg[col - 1] not in wseps + [" ", "\t"]:
                     col -= 1
                 if col >= 0:
                     col -= 1
@@ -902,7 +908,7 @@
         @return list of calltips (list of string)
         """
         calltips = []
-        if module:
+        if module and bool(editor.getLexer()):
             if prefix:
                 # prefix can be 'self', 'cls' or a class name
                 sep = editor.getLexer().autoCompletionWordSeparators()[0]

eric ide

mercurial