Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upFix crash when setBreakpoint from VSCode sends a git:/ URI... #1000
Conversation
|
Wait, it looks like we already have a test for a path like this and it's expected as a possible in-memory input path: @rkeithhill is it possible this is already fixed? |
|
@rjmholt multiple folks mentioned the debug adapter in the issues... it could be a different code path? |
| @@ -174,6 +180,20 @@ public ScriptFile GetFile(string filePath) | |||
| /// <param name="scriptFile">The out parameter that will contain the ScriptFile object.</param> | |||
| public bool TryGetFile(string filePath, out ScriptFile scriptFile) | |||
| { | |||
| try | |||
| { | |||
| if (filePath.Contains(":/") // Quick heuristic to determine if we might have a URI | |||
rkeithhill
Aug 2, 2019
Collaborator
I thought I had suggested a code change like this before but we eventually decided that the GetFile() call on line 199 would throw in this case and we'd return false. That said, I'd rather test this in a way that doesn't rely on catching an exception.
I thought I had suggested a code change like this before but we eventually decided that the GetFile() call on line 199 would throw in this case and we'd return false. That said, I'd rather test this in a way that doesn't rely on catching an exception.
rkeithhill
Aug 6, 2019
Collaborator
Yes.
Yes.
rjmholt
Aug 6, 2019
Author
Member
My worry is that there seems to be a test that exists already for a git:/ schemed file. My change would just reject those (and anything else that isn't file, untitled or inmemory). The fact that we already have a test for this makes me feel like there is an expectation that we can understand and handle a URI like this -- does that seem right?
My worry is that there seems to be a test that exists already for a git:/ schemed file. My change would just reject those (and anything else that isn't file, untitled or inmemory). The fact that we already have a test for this makes me feel like there is an expectation that we can understand and handle a URI like this -- does that seem right?
rkeithhill
Aug 14, 2019
Collaborator
Those tests for git:/ and gitlens-git:/ look like my tests. I think the intent here was to have those uri schemes return true for IsInMemory which we used to signal that you can't do things like set breakpoints with an "in memory" document. In retrospect, perhaps that is not the best approach RE the way we used IsInMemory but the basic idea was to determine whether or not we had a file path we could provide to Set-PSBreakpoint.
Those tests for git:/ and gitlens-git:/ look like my tests. I think the intent here was to have those uri schemes return true for IsInMemory which we used to signal that you can't do things like set breakpoints with an "in memory" document. In retrospect, perhaps that is not the best approach RE the way we used IsInMemory but the basic idea was to determine whether or not we had a file path we could provide to Set-PSBreakpoint.
rkeithhill
Aug 14, 2019
•
Collaborator
In an ideal design, I could walk up to the ScriptFile/EditorDocument and query a property like CanHaveBreakpoints or something like that to determine whether or not an LSP text document could have a breakpoint set on it. But I think this is good as a stop-gap. Ship it! 
In an ideal design, I could walk up to the ScriptFile/EditorDocument and query a property like CanHaveBreakpoints or something like that to determine whether or not an LSP text document could have a breakpoint set on it. But I think this is good as a stop-gap. Ship it! ![]()
The stack trace I'm working against looks like this:
So |
|
LGTM |
974bb1d
into
PowerShell:master
…hell#1000) * Fix git uri problem * Remove unused imports
Fixes PowerShell/vscode-powershell#1994