Show More
@@ -11,6 +11,7 b' except ImportError:' | |||
|
11 | 11 | |
|
12 | 12 | from IPython.config import Configurable |
|
13 | 13 | from IPython.core.completer import IPCompleter |
|
14 | from IPython.utils.py3compat import str_to_unicode, cast_bytes, unicode_to_str | |
|
14 | 15 | from IPython.utils.traitlets import Float |
|
15 | 16 | import IPython.utils.rlineimpl as readline |
|
16 | 17 | |
@@ -36,8 +37,17 b' class ZMQCompleter(IPCompleter):' | |||
|
36 | 37 | self.readline.set_completer_delims('\r\n') |
|
37 | 38 | |
|
38 | 39 | def complete_request(self, text): |
|
39 | line = readline.get_line_buffer() | |
|
40 | cursor_pos = readline.get_endidx() | |
|
40 | line = str_to_unicode(readline.get_line_buffer()) | |
|
41 | byte_cursor_pos = readline.get_endidx() | |
|
42 | ||
|
43 | # get_endidx is a byte offset | |
|
44 | # account for multi-byte characters to get correct cursor_pos | |
|
45 | cursor_pos = byte_cursor_pos | |
|
46 | i = 0 | |
|
47 | while i < cursor_pos: | |
|
48 | bytelen = len(cast_bytes(line[i])) | |
|
49 | cursor_pos -= (bytelen-1) | |
|
50 | i += 1 | |
|
41 | 51 | |
|
42 | 52 | # send completion request to kernel |
|
43 | 53 | # Give the kernel up to 5s to respond |
@@ -54,6 +64,7 b' class ZMQCompleter(IPCompleter):' | |||
|
54 | 64 | if content["cursor_end"] < cursor_pos: |
|
55 | 65 | extra = line[content["cursor_end"]: cursor_pos] |
|
56 | 66 | matches = [m + extra for m in matches] |
|
67 | matches = [ unicode_to_str(m) for m in matches ] | |
|
57 | 68 | return matches |
|
58 | 69 | return [] |
|
59 | 70 |
General Comments 0
You need to be logged in to leave comments.
Login now