canon 0.3.42 → 0.3.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a54063c501419f65316ce159b9ff85c7179d49afc6a0c7d3d17f5adef2981a0
4
- data.tar.gz: f535a9131aed98326fe7c8fa13c70fe39f2913451b39a83a82d2df6ab636219c
3
+ metadata.gz: 88bb496bdbab5cc434e73d3f353563e110bbaf0b73a76f009886e45743206984
4
+ data.tar.gz: c00284c8cc531ed825633e8e2250a1dbead21ec4db083529a6bef5d3b909bd4b
5
5
  SHA512:
6
- metadata.gz: 82f5cb1c13b63065112deb746b569e9abf902322c8cff3e94568a05db86f605872f739aa15ca0f82ccab425f92494dd5fcfc9f83ee2b99b4a8309c4c34533474
7
- data.tar.gz: 72002e2e958716c54fa353ffd6fffda94b98e7eeac8e05510af5fa92f4c576fe37c2f5c06fa9d44feae84ba8e9a698ededd8405504b49f28620cc29418f21f22
6
+ metadata.gz: 7e32bb5f265281f3ba69a7b9c130025d84f27578084a8a90267edaefc7e5cc6cedd8b2aa72db0a930d38def70ac07f826fc80e767cda72089d3ebedbc88219f4
7
+ data.tar.gz: 82a1b117a2f121dbd436962937b1aec7de7ef691b8d15f51fbf69155d6ff9fe09af5ed5f69efdbfa4724af65dbd3858525a56ac22ebb6d603c91ad9b032ab590
@@ -59,10 +59,55 @@ module Canon
59
59
  grouping_lines: @diff_grouping_lines,
60
60
  )
61
61
 
62
+ # #85/#86: DiffNodes the enricher could not locate were
63
+ # previously dropped silently — the absorption mechanism.
64
+ # Their serialized content renders as a trailing context so
65
+ # the change is always visible, without perturbing the
66
+ # located walk's line accounting.
67
+ append_unlocated_context(report)
68
+
62
69
  # Layer 6: Format the report
63
70
  format_report(report, doc1, doc2)
64
71
  end
65
72
 
73
+ # Trailing context for DiffNodes with no located char ranges
74
+ # (multiline reflowed text, relocated content): one removed
75
+ # DiffLine per serialized_before line, one added per
76
+ # serialized_after line. Nil positions render as blank line
77
+ # numbers.
78
+ def append_unlocated_context(report)
79
+ unlocated = @differences.select do |dn|
80
+ dn.char_ranges.nil? || dn.char_ranges.empty?
81
+ end
82
+ return if unlocated.empty?
83
+
84
+ unlocated = unlocated.reject do |dn|
85
+ (@show_diffs == :normative && !dn.normative?) ||
86
+ (@show_diffs == :informative && !dn.informative?)
87
+ end
88
+ return if unlocated.empty?
89
+
90
+ lines = []
91
+ unlocated.each do |dn|
92
+ fmt = dn.formatting?
93
+ dn.serialized_before&.split("\n")&.each do |line|
94
+ lines << Canon::Diff::DiffLine.new(
95
+ line_number: nil, new_position: nil, content: line,
96
+ type: :removed, diff_node: dn, formatting: fmt
97
+ )
98
+ end
99
+ next unless dn.serialized_after
100
+
101
+ dn.serialized_after.split("\n").each do |line|
102
+ lines << Canon::Diff::DiffLine.new(
103
+ line_number: nil, new_position: nil, content: line,
104
+ type: :added, diff_node: dn, formatting: fmt
105
+ )
106
+ end
107
+ end
108
+ report.contexts << Canon::Diff::DiffContext.new(lines: lines)
109
+ end
110
+
66
111
  # Format a DiffReport for display
67
112
  def format_report(report, doc1, doc2)
68
113
  return "" if report.contexts.empty?
@@ -100,12 +145,12 @@ module Canon
100
145
  context.lines.each do |diff_line|
101
146
  case diff_line.type
102
147
  when :unchanged
103
- old_num = diff_line.line_number + 1
104
- new_num = (diff_line.new_position || diff_line.line_number) + 1
148
+ old_num = diff_line.line_number&.+(1)
149
+ new_num = (diff_line.new_position || diff_line.line_number)&.+(1)
105
150
  output << format_unified_line(old_num, new_num, " ",
106
151
  diff_line.content)
107
152
  when :removed
108
- line_num = diff_line.line_number + 1
153
+ line_num = diff_line.line_number&.+(1)
109
154
  formatting = diff_line.formatting?
110
155
  informative = diff_line.informative?
111
156
 
@@ -147,7 +192,7 @@ module Canon
147
192
  theme_color(:removed, :content))
148
193
  end
149
194
  when :added
150
- line_num = (diff_line.new_position || diff_line.line_number) + 1
195
+ line_num = (diff_line.new_position || diff_line.line_number)&.+(1)
151
196
  formatting = diff_line.formatting?
152
197
  informative = diff_line.informative?
153
198
 
@@ -255,8 +300,8 @@ module Canon
255
300
  # Format a changed diff line using DiffCharRanges for character-level highlighting.
256
301
  # Reads pre-computed char ranges from the DiffLine — NO tokenization, NO LCS.
257
302
  def format_changed_line(diff_line, _lines1)
258
- old_line_num = diff_line.line_number + 1
259
- new_line_num = (diff_line.new_position || diff_line.line_number) + 1
303
+ old_line_num = diff_line.line_number&.+(1)
304
+ new_line_num = (diff_line.new_position || diff_line.line_number)&.+(1)
260
305
  formatting = diff_line.formatting?
261
306
  informative = diff_line.informative?
262
307
  old_content = diff_line.old_content || diff_line.content
data/lib/canon/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Canon
4
- VERSION = "0.3.42"
4
+ VERSION = "0.3.43"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.42
4
+ version: 0.3.43
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.