fix: matchedText module resolution incorrect length#21647
Conversation
2b4156c to
3a66b8e
Compare
…e candidate closes: microsoft#21636
3a66b8e to
18847f9
Compare
|
@Andy-MS can you take a look at this please? Thanks |
|
|
||
| // @filename: c:/root/index.ts | ||
| import {x} from "@speedy/folder1/testing" | ||
| declare function use(a: any): void; |
There was a problem hiding this comment.
Are these two lines necessary? --noUnusedLocals is disabled by default.
There was a problem hiding this comment.
In that case it's safe to remove
| Debug.assert(isPatternMatch(pattern, candidate)); | ||
| return candidate.substr(pattern.prefix.length, candidate.length - pattern.suffix.length); | ||
| const matchLength = candidate.length - pattern.suffix.length - pattern.prefix.length; | ||
| return candidate.substr(pattern.prefix.length, matchLength); |
There was a problem hiding this comment.
Could use slice which takes start and end and is more common in the rest of the codebase. substr leads to nothing but problems (#20578).
There was a problem hiding this comment.
I think you meant substring not slice slice but i get your point :)
There was a problem hiding this comment.
Looks like we use them both about as often. According to this slice and substring are basically equivalent with the exception of error handling -- if you avoid negative numbers, NaN, and start > end, they're the same.
794c673 to
d59a360
Compare
d59a360 to
d01d068
Compare
|
@Andy-MS thanks for the review. Updated as suggested! |
matchedTextwas not properly extract the correct parts from the candidate.Fixes #21636