Skip to content

Fix #323: DSC IntelliSense can cause language service to crash #324

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

Merged
merged 2 commits into from
Dec 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions scripts/FetchLatestBuild.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,13 @@ function Install-BuildPackage($packageName, $extension) {
mkdir $binariesToSignPath -Force | Out-Null
cp "$packageContentPath\lib\net45\$packageName.$extension" -Force -Destination $binariesToSignPath

# Don't forget the x86 exe
if ($extension -eq "exe") {
cp "$packageContentPath\lib\net45\$packageName.x86.$extension" -Force -Destination $binariesToSignPath
}

Write-Output "Extracted package $packageName ($buildVersion)"
}

# Pull the build packages from AppVeyor
Install-BuildPackage "Microsoft.PowerShell.EditorServices" "dll"
Install-BuildPackage "Microsoft.PowerShell.EditorServices.Protocol" "dll"
Install-BuildPackage "Microsoft.PowerShell.EditorServices.Host" "exe"
Install-BuildPackage "Microsoft.PowerShell.EditorServices.Host" "dll"

# Open the BinariesToSign folder
& start $binariesToSignPath
42 changes: 26 additions & 16 deletions src/PowerShellEditorServices/Language/LanguageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,23 +102,33 @@ await this.powerShellContext.GetRunspaceHandle(

if (commandCompletion != null)
{
CompletionResults completionResults =
CompletionResults.Create(
scriptFile,
commandCompletion);

// save state of most recent completion
mostRecentCompletions = completionResults;
mostRecentRequestFile = scriptFile.Id;
mostRecentRequestLine = lineNumber;
mostRecentRequestOffest = columnNumber;

return completionResults;
}
else
{
return new CompletionResults();
try
{
CompletionResults completionResults =
CompletionResults.Create(
scriptFile,
commandCompletion);

// save state of most recent completion
mostRecentCompletions = completionResults;
mostRecentRequestFile = scriptFile.Id;
mostRecentRequestLine = lineNumber;
mostRecentRequestOffest = columnNumber;

return completionResults;
}
catch(ArgumentException e)
{
// Bad completion results could return an invalid
// replacement range, catch that here
Logger.Write(
LogLevel.Error,
$"Caught exception while trying to create CompletionResults:\n\n{e.ToString()}");
}
}

// If all else fails, return empty results
return new CompletionResults();
}

/// <summary>
Expand Down