##// END OF EJS Templates
Correctly count newline in tokenize....
Matthias Bussonnier -
Show More
@@ -13,7 +13,7 b' def expect_token(expected, cell, cursor_pos):'
13 if offset + len(line) >= cursor_pos:
13 if offset + len(line) >= cursor_pos:
14 break
14 break
15 else:
15 else:
16 offset += len(line)
16 offset += len(line)+1
17 column = cursor_pos - offset
17 column = cursor_pos - offset
18 line_with_cursor = '%s|%s' % (line[:column], line[column:])
18 line_with_cursor = '%s|%s' % (line[:column], line[column:])
19 nt.assert_equal(token, expected,
19 nt.assert_equal(token, expected,
@@ -88,3 +88,15 b' def test_line_at_cursor():'
88 (line, offset) = line_at_cursor(cell, cursor_pos=11)
88 (line, offset) = line_at_cursor(cell, cursor_pos=11)
89 assert line == "", ("Expected '', got %r" % line)
89 assert line == "", ("Expected '', got %r" % line)
90 assert offset == 0, ("Expected '', got %r" % line)
90 assert offset == 0, ("Expected '', got %r" % line)
91
92 def test_muliline_statement():
93 cell = """a = (1,
94 3)
95
96 int()
97 map()
98 """
99 for c in range(16, 22):
100 yield lambda: expect_token("int", cell, c)
101 for c in range(22, 28):
102 yield lambda: expect_token("map", cell, c)
@@ -108,7 +108,7 b' def token_at_cursor(cell, cursor_pos=0):'
108 break
108 break
109
109
110 tokens.append(tok)
110 tokens.append(tok)
111 if tok.token == tokenize2.NEWLINE:
111 if tok.token in (tokenize2.NEWLINE, tokenize2.NL):
112 offset += len(tok.line)
112 offset += len(tok.line)
113
113
114 if call_names:
114 if call_names:
General Comments 0
You need to be logged in to leave comments. Login now