##// END OF EJS Templates
simplify byte-offset -> character offset...
Min RK -
Show More
@@ -11,7 +11,7 b' except ImportError:'
11
11
12 from IPython.config import Configurable
12 from IPython.config import Configurable
13 from IPython.core.completer import IPCompleter
13 from IPython.core.completer import IPCompleter
14 from IPython.utils.py3compat import str_to_unicode, cast_bytes, unicode_to_str
14 from IPython.utils.py3compat import str_to_unicode, unicode_to_str, cast_bytes, cast_unicode
15 from IPython.utils.traitlets import Float
15 from IPython.utils.traitlets import Float
16 import IPython.utils.rlineimpl as readline
16 import IPython.utils.rlineimpl as readline
17
17
@@ -42,12 +42,8 b' class ZMQCompleter(IPCompleter):'
42
42
43 # get_endidx is a byte offset
43 # get_endidx is a byte offset
44 # account for multi-byte characters to get correct cursor_pos
44 # account for multi-byte characters to get correct cursor_pos
45 cursor_pos = byte_cursor_pos
45 bytes_before_cursor = cast_bytes(line)[:byte_cursor_pos]
46 i = 0
46 cursor_pos = len(cast_unicode(bytes_before_cursor))
47 while i < cursor_pos:
48 bytelen = len(cast_bytes(line[i]))
49 cursor_pos -= (bytelen-1)
50 i += 1
51
47
52 # send completion request to kernel
48 # send completion request to kernel
53 # Give the kernel up to 5s to respond
49 # Give the kernel up to 5s to respond
General Comments 0
You need to be logged in to leave comments. Login now