Skip to content

Apply source map section columns only to their first line - #843

Open
OskarEichler wants to merge 1 commit into
rails:mainfrom
OskarEichler:codex/columns-source-fix
Open

Apply source map section columns only to their first line#843
OskarEichler wants to merge 1 commit into
rails:mainfrom
OskarEichler:codex/columns-source-fix

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary

Index source map column offsets apply only to the first generated line of each section, while line offsets apply to all lines.

Matches ECMA-426 DecodeIndexSourceMap: column offset applies to the first generated line only. Sprockets represents generated lines starting at 1.

Reproduction

With require "sprockets"; require "tmpdir":

map = {"version"=>3, "file"=>"a.js", "sources"=>["a.js"], "names"=>[], "mappings"=>"AAAA;AACA"}
index = {"version"=>3, "sections"=>[{"offset"=>{"line"=>5,"column"=>7}, "map"=>map}]}
p Sprockets::SourceMapUtils.decode_source_map(index)[:mappings].map { |m| m[:generated] }
# [[6,7], [7,0]]; previously [[6,7], [7,7]].

Verification

  • Isolated patch and release baseline: unchanged bundle exec rake test, 913 tests /4,109 assertions /zero failures/errors /four skips, Ruby 3.2.11 and 4.0.6. 54 focused external checks for this patch on each Ruby.
  • Eight follow-ups combined with existing Use Ruby 3 keyword argument handling for find_asset! #792: same suite plus 1,540 focused checks per Ruby. Combined isolated test task also passes. Full RuboCop passes all 133 files; Ruby syntax and diff whitespace checks pass.
  • Gem build preserves 84 file paths, version 4.4.1, Ruby >=2.5 and dependency metadata. Consumer based on installed release/current main 49d9f20c00ac7d9a7ee57db058961edcccd86699, without unrelated upgrades.
  • Existing asset-clean test is timing-sensitive: touching its fixture within the current timestamp second reproduced the same line-80 assertion failure on baseline and an independent cache patch (2/4 each). Full successful runs above are actual runs; no test code was changed. Normal skips cover legacy Ruby, Windows and two Sass cases; non-terminal stdin adds the Unix-device skip.

Compatibility and limitations

Breaking changes: no intentional change to valid supported behavior; the incorrect behavior above changes. No new dependencies or version upgrades. Older Ruby/Linux/JRuby checks are left to upstream CI, not claimed locally. No tests added/edited under the consumer repository's no-test-edit policy; focused evidence was run externally. Prepared with AI assistance. This is a focused correction, not an exhaustive Sprockets review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant