##// END OF EJS Templates
Fix error in completer when the cursor position is at the start of a...
Ian Rose -
Show More
@@ -1129,20 +1129,21 b' class IPCompleter(Completer):'
1129 if self.global_namespace is not None:
1129 if self.global_namespace is not None:
1130 namespaces.append(self.global_namespace)
1130 namespaces.append(self.global_namespace)
1131
1131
1132 completion_filter = lambda x:x
1132 # cursor_pos is an it, jedi wants line and column
1133 # cursor_pos is an it, jedi wants line and column
1133 offset = cursor_to_position(text, cursor_line, cursor_column)
1134 offset = cursor_to_position(text, cursor_line, cursor_column)
1135 # filter output if we are completing for object members
1134 if offset:
1136 if offset:
1135 pre = text[offset-1]
1137 pre = text[offset-1]
1136 completion_filter = lambda x:x
1138 if pre == '.':
1137 if pre == '.':
1139 if self.omit__names == 2:
1138 if self.omit__names == 2:
1140 completion_filter = lambda c:not c.name.startswith('_')
1139 completion_filter = lambda c:not c.name.startswith('_')
1141 elif self.omit__names == 1:
1140 elif self.omit__names == 1:
1142 completion_filter = lambda c:not (c.name.startswith('__') and c.name.endswith('__'))
1141 completion_filter = lambda c:not (c.name.startswith('__') and c.name.endswith('__'))
1143 elif self.omit__names == 0:
1142 elif self.omit__names == 0:
1144 completion_filter = lambda x:x
1143 completion_filter = lambda x:x
1145 else:
1144 else:
1146 raise ValueError("Don't understand self.omit__names == {}".format(self.omit__names))
1145 raise ValueError("Don't understand self.omit__names == {}".format(self.omit__names))
1146
1147
1147 interpreter = jedi.Interpreter(
1148 interpreter = jedi.Interpreter(
1148 text, namespaces, column=cursor_column, line=cursor_line + 1)
1149 text, namespaces, column=cursor_column, line=cursor_line + 1)
@@ -1150,7 +1151,7 b' class IPCompleter(Completer):'
1150 return filter(completion_filter, interpreter.completions())
1151 return filter(completion_filter, interpreter.completions())
1151 except Exception as e:
1152 except Exception as e:
1152 if self.debug:
1153 if self.debug:
1153 return [_FakeJediCompletion('Opps Jedi has crash please report a bug with the following:\n"""\n%s\ns"""' % (e))]
1154 return [_FakeJediCompletion('Oops Jedi has crashed, please report a bug with the following:\n"""\n%s\ns"""' % (e))]
1154 else:
1155 else:
1155 return []
1156 return []
1156
1157
General Comments 0
You need to be logged in to leave comments. Login now