-
Notifications
You must be signed in to change notification settings - Fork 741
Handle nil end position in getMappedLocation #1920
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
17a4f9e
6ffa90f
8103882
eb68a0b
b760558
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,12 @@ func (l *LanguageService) getMappedLocation(fileName string, fileRange core.Text | |
| } | ||
| } | ||
| endPos := l.tryGetSourcePosition(fileName, core.TextPos(fileRange.End())) | ||
| if endPos == nil { | ||
| endPos = &sourcemap.DocumentPosition{ | ||
| FileName: startPos.FileName, | ||
| Pos: startPos.Pos + fileRange.Len(), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks right as a port, but since this is happening, do we need to ensure this position is inside the length of the file?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure; my understanding is that the conversion to an LSP range will clamp it via the line map, but maybe not... I can grab the script and
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, I can. I'm questioning whether or not it's a good idea, though, given we don't do the same sort of bounds checks when going from an LSP position to a byte position... Could go either way. Either way it's sort of papering over something. |
||
| } | ||
| } | ||
| debug.Assert(endPos.FileName == startPos.FileName, "start and end should be in same file") | ||
| newRange := core.NewTextRange(startPos.Pos, endPos.Pos) | ||
| lspRange := l.createLspRangeFromRange(newRange, l.getScript(startPos.FileName)) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| // === findAllReferences === | ||
| // === /findAllRefsForDefaultExport03.ts === | ||
| // /*FIND ALL REFS*/function [|f|]() { | ||
| // return 100; | ||
| // } | ||
| // | ||
| // export default [|f|]; | ||
| // | ||
| // var x: typeof [|f|]; | ||
| // | ||
| // var y = [|f|](); | ||
| // | ||
| // namespace [|f|] { | ||
| // var local = 100; | ||
| // } | ||
|
|
||
|
|
||
|
|
||
| // === findAllReferences === | ||
| // === /findAllRefsForDefaultExport03.ts === | ||
| // function /*FIND ALL REFS*/[|f|]() { | ||
| // return 100; | ||
| // } | ||
| // | ||
| // export default [|f|]; | ||
| // | ||
| // var x: typeof [|f|]; | ||
| // | ||
| // var y = [|f|](); | ||
| // | ||
| // namespace [|f|] { | ||
| // var local = 100; | ||
| // } | ||
|
|
||
|
|
||
|
|
||
| // === findAllReferences === | ||
| // === /findAllRefsForDefaultExport03.ts === | ||
| // function [|f|]() { | ||
| // return 100; | ||
| // } | ||
| // | ||
| // /*FIND ALL REFS*/export default [|f|]; | ||
| // | ||
| // var x: typeof [|f|]; | ||
| // | ||
| // var y = [|f|](); | ||
| // | ||
| // namespace [|f|] { | ||
| // var local = 100; | ||
| // } | ||
|
|
||
|
|
||
|
|
||
| // === findAllReferences === | ||
| // === /findAllRefsForDefaultExport03.ts === | ||
| // function [|f|]() { | ||
| // return 100; | ||
| // } | ||
| // | ||
| // export default /*FIND ALL REFS*/[|f|]; | ||
| // | ||
| // var x: typeof [|f|]; | ||
| // | ||
| // var y = [|f|](); | ||
| // | ||
| // namespace [|f|] { | ||
| // var local = 100; | ||
| // } | ||
|
|
||
|
|
||
|
|
||
| // === findAllReferences === | ||
| // === /findAllRefsForDefaultExport03.ts === | ||
| // function [|f|]() { | ||
| // return 100; | ||
| // } | ||
| // | ||
| // export default [|f|]; | ||
| // | ||
| // var x: typeof /*FIND ALL REFS*/[|f|]; | ||
| // | ||
| // var y = [|f|](); | ||
| // | ||
| // namespace [|f|] { | ||
| // var local = 100; | ||
| // } | ||
|
|
||
|
|
||
|
|
||
| // === findAllReferences === | ||
| // === /findAllRefsForDefaultExport03.ts === | ||
| // function [|f|]() { | ||
| // return 100; | ||
| // } | ||
| // | ||
| // export default [|f|]; | ||
| // | ||
| // var x: typeof [|f|]; | ||
| // | ||
| // var y = /*FIND ALL REFS*/[|f|](); | ||
| // | ||
| // namespace [|f|] { | ||
| // var local = 100; | ||
| // } | ||
|
|
||
|
|
||
|
|
||
| // === findAllReferences === | ||
| // === /findAllRefsForDefaultExport03.ts === | ||
| // function [|f|]() { | ||
| // return 100; | ||
| // } | ||
| // | ||
| // export default [|f|]; | ||
| // | ||
| // var x: typeof [|f|]; | ||
| // | ||
| // var y = [|f|](); | ||
| // | ||
| // /*FIND ALL REFS*/namespace [|f|] { | ||
| // var local = 100; | ||
| // } | ||
|
|
||
|
|
||
|
|
||
| // === findAllReferences === | ||
| // === /findAllRefsForDefaultExport03.ts === | ||
| // function [|f|]() { | ||
| // return 100; | ||
| // } | ||
| // | ||
| // export default [|f|]; | ||
| // | ||
| // var x: typeof [|f|]; | ||
| // | ||
| // var y = [|f|](); | ||
| // | ||
| // namespace /*FIND ALL REFS*/[|f|] { | ||
| // var local = 100; | ||
| // } |
Uh oh!
There was an error while loading. Please reload this page.