@@ -139,21 +139,38 @@ function Buffer:set_extmarks(extmarks)
139
139
end
140
140
141
141
function Buffer :set_line_highlights (highlights )
142
- local line_ansi_colorized = {}
142
+ local line_ansi_colorized_map = {}
143
143
144
144
for _ , hl in ipairs (highlights ) do
145
145
local line_nr , hl_group = unpack (hl )
146
146
if hl_group == " NeogitDiffContext" then
147
- if not line_ansi_colorized [line_nr ] then
148
- local text = self :get_line (line_nr + 1 )
149
- vim .g .baleia .buf_set_lines (self .handle , line_nr , line_nr + 1 , false , text )
150
- line_ansi_colorized [line_nr ] = true
151
- end
147
+ line_ansi_colorized_map [line_nr ] = true
148
+ else
149
+ self :add_line_highlight (unpack (hl ))
152
150
end
151
+ end
153
152
154
- if not line_ansi_colorized [line_nr ] then
155
- self :add_line_highlight (unpack (hl ))
153
+ local line_ansi_colorized = {}
154
+ for k in pairs (line_ansi_colorized_map ) do
155
+ table.insert (line_ansi_colorized , k )
156
+ end
157
+ table.sort (line_ansi_colorized )
158
+
159
+ local start_line_nr , prev_line_nr
160
+ for _ , line_nr in ipairs (line_ansi_colorized ) do
161
+ if start_line_nr == nil then
162
+ start_line_nr = line_nr
156
163
end
164
+ if prev_line_nr ~= nil and line_nr ~= prev_line_nr + 1 then
165
+ local text = self :get_lines (start_line_nr , prev_line_nr + 1 , false )
166
+ vim .g .baleia .buf_set_lines (self .handle , start_line_nr , prev_line_nr + 1 , false , text )
167
+ start_line_nr = line_nr
168
+ end
169
+ prev_line_nr = line_nr
170
+ end
171
+ if start_line_nr ~= nil then
172
+ local text = self :get_lines (start_line_nr , prev_line_nr + 1 , false )
173
+ vim .g .baleia .buf_set_lines (self .handle , start_line_nr , prev_line_nr + 1 , false , text )
157
174
end
158
175
end
159
176
0 commit comments