Skip to content

Fine tune slice range to fix #170#180

Closed
glromeo wants to merge 1 commit intoistanbuljs:masterfrom
glromeo:slice-range-end
Closed

Fine tune slice range to fix #170#180
glromeo wants to merge 1 commit intoistanbuljs:masterfrom
glromeo:slice-range-end

Conversation

@glromeo
Copy link
Copy Markdown
Contributor

@glromeo glromeo commented Jan 19, 2022

@bcoe I isolated in this PR the fix for #170

In the PR #172 I implemented

while (end < lines.length && extStartCol < lines[end].endCol && endCol >= lines[end].startCol) {
++end
}

with a conservative mindset leaving the endCol >= lines.startCol that was originally in
const lines = this.lines.filter((line, i) => {
return startCol <= line.endCol && endCol >= line.startCol
})
if (!lines.length) return {}

and this >= is the cause of #170

This PR aims at fixing #170 with the least side effects as possible.

C8 is fine

Screenshot 2022-01-19 at 02 12 14

The changes in the snapshot reflect the end of the range being exclusive (https://v8.dev/blog/javascript-code-coverage)

Screenshot 2022-01-19 at 02 31 33

while 538 corresponds to 37:0 so line 37 cannot be taken in the range

@bcoe
Copy link
Copy Markdown
Member

bcoe commented Feb 5, 2022

@glromeo this looks reasonable to me, because the line ranges are so finicky, I will probably still test on a few other codebases before merging ... if I recall the remapping step of applying source maps was most sensitive to small changes like this, I'd like to test against a few large TypeScript codebases.

"end": Object {
"column": 0,
"line": 37,
"column": 29,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The column changing significantly concerns me a little bit, because I think it suggests we identified a different statement, this is where source maps can really start to behave drastically different.

A good TypeScript codebase to test on is this one:

https://github.com/googleapis/release-please

and this one:

https://github.com/yargs/yargs

@glromeo
Copy link
Copy Markdown
Contributor Author

glromeo commented Feb 28, 2022

@bcoe sorry for taking so long...I needed a break to come back to this problem with a fresh mindset and I think I might indeed have a better idea of how to solve it.
I consider this a dead end because it coincidentally solves the problem of #170 by always going one mapping short which in the case of tsc where the mapping for } is actually present ends up being wrong!

@glromeo glromeo closed this Feb 28, 2022
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.

2 participants