Skip to content

Commit 2060403

Browse files
committed
fix,ui: fix thread preview and change add/remove sign placement
Signed-off-by: Louis DeLosSantos <louis.delos@gmail.com>
1 parent c273940 commit 2060403

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

lua/litee/gh/pr/thread_buffer.lua

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,19 +358,32 @@ local function write_preview(thread, buffer_lines, lines_to_highlight, hi, line_
358358
table.insert(tmp, lines[i])
359359
end
360360
if #tmp > 0 then
361-
comment_line = comment_line - #tmp
361+
local prev_symbol = ""
362+
comment_line = (comment_line - #tmp)-1
362363
for i = #tmp, 1, -1 do
363364
local l = tmp[i]
364-
local buf_line = string.format("%d ▏%s", comment_line, l)
365-
table.insert(buffer_lines, buf_line)
366365
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)
367372
table.insert(lines_to_highlight, {#buffer_lines, "DiffAdd"})
373+
prev_symbol = "+"
368374
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)
369379
table.insert(lines_to_highlight, {#buffer_lines, "DiffDelete"})
380+
prev_symbol = "-"
370381
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)
371385
table.insert(lines_to_highlight, {#buffer_lines, hi})
372386
end
373-
comment_line = comment_line + 1
374387
end
375388
end
376389
end

0 commit comments

Comments
 (0)