Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Indexed column spans ignore section line offsets when clipping at the next section

Đang mở Phù hợp với người mới
#539 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

@NUAAwqy đang làm issue này rồi.

Từ ngày 13/10/2026.

  • #540 của @NUAAwqy — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript
Lĩnh vực
tooling

Hướng nghiên cứu

Bắt đầu từ script tái tạo lỗi, script này dùng SourceMapConsumer với hai section có chỉ mục mà offset nằm ở dòng 4. Gọi computeColumnSpans() và kiểm tra generatedPositionFor, allGeneratedPositionsFor và eachMapping. Lỗi nằm ở chỗ kiểm tra ranh giới section so sánh dòng được tạo cục bộ trong section với dòng tuyệt đối của section tiếp theo trước khi offset được áp dụng. Công việc được coi là xong khi mapping đầu tiên kết thúc ở cột 9 và các test hồi quy cho cả ba API đều pass, bao gồm một trường hợp có ranh giới ở dòng cục bộ phía sau.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Indexed maps whose first section has a nonzero line offset return a column span that extends into the next section on the same generated line.

Minimal reproduction on master (8c668f3):

const { SourceMapConsumer } = require("source-map");

(async () => {
  const consumer = await new SourceMapConsumer({
    version: 3,
    sections: [
      {
        offset: { line: 4, column: 3 },
        map: { version: 3, sources: ["first.js"], names: [], mappings: "AAAA" },
      },
      {
        offset: { line: 4, column: 10 },
        map: { version: 3, sources: ["second.js"], names: [], mappings: "AAAA" },
      },
    ],
  });
  try {
    consumer.computeColumnSpans();
    console.log(consumer.generatedPositionFor({
      source: "first.js", line: 1, column: 0,
    }));
    console.log(consumer.allGeneratedPositionsFor({
      source: "first.js", line: 1, column: 0,
    }));
    consumer.eachMapping(console.log);
  } finally {
    consumer.destroy();
  }
})();

Expected: the first mapping is at generated line 5, column 3, with an inclusive last column of 9 because the second section starts at column 10.

Actual: both position queries return lastColumn: Infinity, and eachMapping returns lastGeneratedColumn: Infinity for that mapping.

The section-boundary check compares a section-local generated line to the next section's absolute generated line before applying the line offset. The same ordering occurs in all three APIs. A boundary on a later local line is affected too; a zero line offset hides the problem.

I have a focused fix and regression tests ready. All 202 tests and lint pass with the fix; the three affected API tests fail on the original code.

Ngôn ngữ chính
JavaScript
Star
3.7k
Fork
374
Merge trung bình
4 ngày 18 giờ
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của mozilla/source-map

Tất cả issue của mozilla/source-map

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.