+30
-3
lines changedFilter options
+30
-3
lines changed Original file line number Diff line number Diff line change
@@ -138,10 +138,18 @@ local function compute_start_range(prev_lines, curr_lines, firstline, lastline,
138
138
-- new lines(O), the new newline is inserted at the line indicated by
139
139
-- new_lastline.
140
140
if firstline == lastline then
141
+
local line_idx
141
142
local line = prev_lines[firstline - 1]
142
-
byte_idx = #line + 1
143
-
char_idx = compute_line_length(line, offset_encoding) + 1
144
-
return { line_idx = firstline - 1, byte_idx = byte_idx, char_idx = char_idx }
143
+
if line then
144
+
line_idx = firstline - 1
145
+
byte_idx = #line + 1
146
+
char_idx = compute_line_length(line, offset_encoding) + 1
147
+
else
148
+
line_idx = firstline
149
+
byte_idx = 1
150
+
char_idx = 1
151
+
end
152
+
return { line_idx = line_idx, byte_idx = byte_idx, char_idx = char_idx }
145
153
end
146
154
147
155
-- If firstline == new_lastline, the first change occurred on a line that was deleted.
Original file line number Diff line number Diff line change
@@ -259,6 +259,25 @@ describe('incremental synchronization', function()
259
259
}
260
260
test_edit({""}, {"o"}, expected_text_changes, 'utf-16', '\n')
261
261
end)
262
+
it('insert a line above the current line', function()
263
+
local expected_text_changes = {
264
+
{
265
+
range = {
266
+
['start'] = {
267
+
character = 0,
268
+
line = 0
269
+
},
270
+
['end'] = {
271
+
character = 0,
272
+
line = 0
273
+
}
274
+
},
275
+
rangeLength = 0,
276
+
text = '\n'
277
+
}
278
+
}
279
+
test_edit({""}, {"O"}, expected_text_changes, 'utf-16', '\n')
280
+
end)
262
281
end)
263
282
describe('multi line edit', function()
264
283
it('deletion and insertion', function()
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4