@@ -358,19 +358,32 @@ local function write_preview(thread, buffer_lines, lines_to_highlight, hi, line_
358
358
table.insert (tmp , lines [i ])
359
359
end
360
360
if # tmp > 0 then
361
- comment_line = comment_line - # tmp
361
+ local prev_symbol = " "
362
+ comment_line = (comment_line - # tmp )- 1
362
363
for i = # tmp , 1 , - 1 do
363
364
local l = tmp [i ]
364
- local buf_line = string.format (" %d ▏%s" , comment_line , l )
365
- table.insert (buffer_lines , buf_line )
366
365
if string.sub (l ,1 ,1 ) == " +" then
366
+ if prev_symbol ~= " -" then
367
+ comment_line = comment_line + 1
368
+ end
369
+ l = string.sub (l , 2 , - 1 )
370
+ local buf_line = string.format (" %d + ▏ %s" , comment_line , l )
371
+ table.insert (buffer_lines , buf_line )
367
372
table.insert (lines_to_highlight , {# buffer_lines , " DiffAdd" })
373
+ prev_symbol = " +"
368
374
elseif string.sub (l ,1 ,1 ) == " -" then
375
+ comment_line = comment_line + 1
376
+ l = string.sub (l , 2 , - 1 )
377
+ local buf_line = string.format (" %d - ▏ %s" , comment_line , l )
378
+ table.insert (buffer_lines , buf_line )
369
379
table.insert (lines_to_highlight , {# buffer_lines , " DiffDelete" })
380
+ prev_symbol = " -"
370
381
else
382
+ comment_line = comment_line + 1
383
+ local buf_line = string.format (" %d ▏ %s" , comment_line , l )
384
+ table.insert (buffer_lines , buf_line )
371
385
table.insert (lines_to_highlight , {# buffer_lines , hi })
372
386
end
373
- comment_line = comment_line + 1
374
387
end
375
388
end
376
389
end
0 commit comments