Show More
@@ -108,6 +108,12 b' def test_line_at_cursor():' | |||||
108 | assert line == "", ("Expected '', got %r" % line) |
|
108 | assert line == "", ("Expected '', got %r" % line) | |
109 | assert offset == 0, ("Expected '', got %r" % line) |
|
109 | assert offset == 0, ("Expected '', got %r" % line) | |
110 |
|
110 | |||
|
111 | # The position after a newline should be the start of the following line. | |||
|
112 | cell = "One\nTwo\n" | |||
|
113 | (line, offset) = line_at_cursor(cell, cursor_pos=4) | |||
|
114 | nt.assert_equal(line, "Two\n") | |||
|
115 | nt.assert_equal(offset, 4) | |||
|
116 | ||||
111 | def test_muliline_statement(): |
|
117 | def test_muliline_statement(): | |
112 | cell = """a = (1, |
|
118 | cell = """a = (1, | |
113 | 3) |
|
119 | 3) |
@@ -44,7 +44,7 b' def line_at_cursor(cell, cursor_pos=0):' | |||||
44 | lines = cell.splitlines(True) |
|
44 | lines = cell.splitlines(True) | |
45 | for line in lines: |
|
45 | for line in lines: | |
46 | next_offset = offset + len(line) |
|
46 | next_offset = offset + len(line) | |
47 |
if next_offset > |
|
47 | if next_offset > cursor_pos: | |
48 | break |
|
48 | break | |
49 | offset = next_offset |
|
49 | offset = next_offset | |
50 | else: |
|
50 | else: |
General Comments 0
You need to be logged in to leave comments.
Login now