|
1 |
| -// Copyright (c) Microsoft Corporation. |
| 1 | +// Copyright (c) Microsoft Corporation. |
2 | 2 | // Licensed under the MIT License.
|
3 | 3 |
|
4 | 4 | using System;
|
@@ -423,29 +423,23 @@ public async Task<string> SetVariableAsync(int variableContainerReferenceId, str
|
423 | 423 | }
|
424 | 424 |
|
425 | 425 | VariableDetailsBase variable = variableContainer.Children[name];
|
426 |
| - // Determine scope in which the variable lives. This is required later for the call to Get-Variable -Scope. |
427 |
| - string scope = null; |
428 |
| - if (variableContainerReferenceId == this.scriptScopeVariables.Id) |
| 426 | + // Determine scope in which the variable lives so we can pass it to `Get-Variable -Scope`. |
| 427 | + string scope = null; // TODO: Can this use a fancy pattern matcher? |
| 428 | + if (variableContainerReferenceId == localScopeVariables.Id) |
429 | 429 | {
|
430 |
| - scope = "Script"; |
| 430 | + scope = VariableContainerDetails.LocalScopeName; |
431 | 431 | }
|
432 |
| - else if (variableContainerReferenceId == this.globalScopeVariables.Id) |
| 432 | + else if (variableContainerReferenceId == scriptScopeVariables.Id) |
433 | 433 | {
|
434 |
| - scope = "Global"; |
| 434 | + scope = VariableContainerDetails.ScriptScopeName; |
435 | 435 | }
|
436 |
| - else |
| 436 | + else if (variableContainerReferenceId == globalScopeVariables.Id) |
437 | 437 | {
|
438 |
| - // Determine which stackframe's local scope the variable is in. |
439 |
| - StackFrameDetails[] stackFrames = await this.GetStackFramesAsync().ConfigureAwait(false); |
440 |
| - for (int i = 0; i < stackFrames.Length; i++) |
441 |
| - { |
442 |
| - var stackFrame = stackFrames[i]; |
443 |
| - } |
| 438 | + scope = VariableContainerDetails.GlobalScopeName; |
444 | 439 | }
|
445 |
| - |
446 |
| - if (scope == null) |
| 440 | + else |
447 | 441 | {
|
448 |
| - // Hmm, this would be unexpected. No scope means do not pass GO, do not collect $200. |
| 442 | + // Hmm, this would be unexpected. No scope means do not pass GO, do not collect $200. |
449 | 443 | throw new Exception("Could not find the scope for this variable.");
|
450 | 444 | }
|
451 | 445 |
|
|
0 commit comments