Skip to content

Commit 9b904fd

Browse files
committed
feat: handle "Erase in Line"
This doesn't color the rest of the line.
1 parent 1af5eea commit 9b904fd

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lua/neogit/lib/buffer.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,16 @@ function Buffer:set_ansi_highlights(highlights)
148148
for _, hl in ipairs(highlights) do
149149
local first_line, last_line = unpack(hl)
150150
local text = self:get_lines(first_line, last_line, false)
151+
152+
for i, line in ipairs(text) do
153+
-- Handle "Erase in Line". This doesn't color the rest of the line.
154+
line = line:gsub("\27%[0K\27%[0m$", "")
155+
if i < #text then
156+
text[i + 1] = "\27[0m" .. text[i + 1]
157+
end
158+
text[i] = line
159+
end
160+
151161
vim.g.baleia.buf_set_lines(self.handle, first_line, last_line, false, text)
152162
end
153163
end

0 commit comments

Comments
 (0)