11local M = {}
22
3- local function pad_connector (str , width )
4- local display = vim .fn .strdisplaywidth (str )
5- if display >= width then
6- return str
7- end
8- return str .. string.rep (" " , width - display )
9- end
10-
11- local function connector_for (chunk_type , position , total , cfg , width )
12- local shapes = cfg [chunk_type ] or cfg .change
13- if not shapes then
14- return pad_connector (cfg .context or " " , width )
15- end
16-
17- local key
18- if total <= 1 then
19- key = " single"
20- elseif position == 1 then
21- key = " start"
22- elseif position == total then
23- key = " finish"
24- else
25- key = " mid"
26- end
27-
28- local value = shapes [key ] or cfg .context or " "
29- return pad_connector (value , width )
30- end
31-
323function M .build (left_lines , right_lines , hunks , config )
334 local connector_width = config .ui .connector_width or 3
34- local connectors_cfg = config . ui . connectors or {}
5+ local blank_connector = string.rep ( " " , connector_width )
356
367 local left_view , right_view , connector_view , line_meta = {}, {}, {}, {}
378 local chunks = {}
389
3910 local prev_a_end = 0
4011 local prev_b_end = 0
4112
42- local function add_line (left_text , right_text , connector_text , meta )
13+ local function add_line (left_text , right_text , meta )
4314 -- Only add actual content lines to each buffer
4415 -- Filler rows exist only in connector view for alignment
4516 local left_index = nil
@@ -58,7 +29,7 @@ function M.build(left_lines, right_lines, hunks, config)
5829 end
5930
6031 -- Connector always has full aligned view
61- connector_view [# connector_view + 1 ] = pad_connector ( connector_text or connectors_cfg . context or " " , connector_width )
32+ connector_view [# connector_view + 1 ] = blank_connector
6233 line_meta [# line_meta + 1 ] = meta
6334
6435 meta .left_index = left_index
@@ -101,7 +72,7 @@ function M.build(left_lines, right_lines, hunks, config)
10172 b_idx = b_idx + 1
10273 end
10374
104- add_line (left_text , right_text , connectors_cfg . context or " " , {
75+ add_line (left_text , right_text , {
10576 kind = " context" ,
10677 chunk = nil ,
10778 left_line = left_line_num ,
@@ -170,25 +141,9 @@ function M.build(left_lines, right_lines, hunks, config)
170141 end
171142 end
172143
173- -- Connector text is driven by per-row kind, not hunk type.
174- -- Add/delete rows (including those produced inside change hunks) are rendered
175- -- via session.lua path rendering (triangles/bars/underlines).
176- local connector_text
177- if kind == " add" or kind == " delete" then
178- connector_text = string.rep (" " , connector_width )
179- elseif kind == " change" then
180- local change_total = math.min (h .left .count , h .right .count )
181- if change_total <= 0 then
182- change_total = 1
183- end
184- connector_text = connector_for (" change" , math.min (i , change_total ), change_total , connectors_cfg , connector_width )
185- else
186- connector_text = connectors_cfg .context or " "
187- end
188-
189144 -- Keep change classification at the line level; intra-line coloring decides blue/green mix.
190-
191- add_line (left_text , right_text , connector_text , {
145+ -- Connector glyphs are rendered from route paths in session.lua.
146+ add_line (left_text , right_text , {
192147 kind = kind ,
193148 chunk = h .index ,
194149 left_line = left_line_num ,
@@ -258,7 +213,7 @@ function M.build(left_lines, right_lines, hunks, config)
258213 b_idx = b_idx + 1
259214 end
260215
261- add_line (left_text , right_text , connectors_cfg . context or " " , {
216+ add_line (left_text , right_text , {
262217 kind = " context" ,
263218 chunk = nil ,
264219 left_line = left_line_num ,
0 commit comments