Skip to content

Conversation

@gaborbernat
Copy link
Contributor

@gaborbernat gaborbernat commented Nov 13, 2025

Fixes assertion failure in getInputFileOffsetForLine when processing files with CRLF line endings. The issue occurred because crAdjustment included the current line's CRLF conversion, but the stored position was captured before processing that conversion.

The fix uses the previous line's crAdjustment value instead, ensuring only adjustments that occurred before the stored position are subtracted. This resolves the timing mismatch that caused negative offset calculations.

Fixes #4343

Fixes assertion failure in getInputFileOffsetForLine when processing
files with CRLF line endings. The issue occurred because crAdjustment
included the current line's CRLF conversion, but the stored position
was captured before processing that conversion.

The fix uses the previous line's crAdjustment value instead, ensuring
only adjustments that occurred before the stored position are subtracted.
This resolves the timing mismatch that caused negative offset calculations.

Fixes universal-ctags#4343
…ine offset functions

The original fix for issue 4343 corrected getInputFileOffsetForLine to prevent negative
calculations by using the previous line's crAdjustment instead of the current line's.
However, this created an inconsistency with compoundPosForOffset (used in binary search),
which still used the current line's crAdjustment.

This inconsistency caused assertion failures in makePromiseForAreaSpecifiedWithOffsets
where startOffset >= startLineOffset was expected to hold true, but the two functions
returned different offset values for the same logical position.

Updated compoundPosForOffset to use the same timing-corrected logic as
getInputFileOffsetForLine, ensuring both functions account for the timing mismatch
where positions are stored before CRLF processing but crAdjustment includes the
current line's CRLF conversion.

Fixes CI failure in parser-xml.r/dos-eol test case while maintaining the original
fix for negative offset calculations in CRLF files.
@codecov
Copy link

codecov bot commented Nov 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.87%. Comparing base (d48558f) to head (e6fbe41).
⚠️ Report is 6 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4349   +/-   ##
=======================================
  Coverage   85.87%   85.87%           
=======================================
  Files         252      252           
  Lines       62597    62614   +17     
=======================================
+ Hits        53755    53772   +17     
  Misses       8842     8842           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

File Offset Calculation Assertion Failure

2 participants