Skip to content

Commit

Permalink
Fix crash trying to edit file when no solution loaded (fixes #37)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamescaper committed Nov 8, 2018
1 parent 5839f8f commit 2c8b60d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public AggregateTypeCompletionProvider(IOptionsProvider optionsProvider, params

public override async Task ProvideCompletionsAsync(CompletionContext context)
{
if (Options == null)
{
// Package not loaded yet (e.g. no solution opened)
return;
}
if (await IsWatchWindowAsync(context).ConfigureAwait(false))
{
// Completions are not usable in watch window
Expand Down Expand Up @@ -80,6 +85,12 @@ public override async Task ProvideCompletionsAsync(CompletionContext context)

public override bool ShouldTriggerCompletion(SourceText text, int caretPosition, CompletionTrigger trigger, OptionSet options)
{
if (Options == null)
{
// Package not loaded yet (e.g. no solution opened)
return false;
}

bool shouldTrigger = triggerCompletions.Any(c => c.ShouldTriggerCompletion(text, caretPosition, trigger, Options));

return shouldTrigger || base.ShouldTriggerCompletion(text, caretPosition, trigger, options);
Expand Down
22 changes: 12 additions & 10 deletions IntelliSenseExtender/Options/OptionsProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ public Options GetOptions()
{
var optionsPage = IntelliSenseExtenderPackage.OptionsPage;

return new Options
{
SortCompletionsAfterImported = optionsPage.SortCompletionsAfterImported,
FilterOutObsoleteSymbols = optionsPage.FilterOutObsoleteSymbols,
SuggestNestedTypes = optionsPage.SuggestNestedTypes,
SuggestTypesOnObjectCreation = optionsPage.SuggestTypesOnObjectCreation,
AddParethesisForNewSuggestions = optionsPage.AddParethesisForNewSuggestions,
SuggestFactoryMethodsOnObjectCreation = optionsPage.SuggestFactoryMethodsOnObjectCreation,
SuggestLocalVariablesFirst = optionsPage.SuggestLocalVariablesFirst
};
return optionsPage == null
? null
: new Options
{
SortCompletionsAfterImported = optionsPage.SortCompletionsAfterImported,
FilterOutObsoleteSymbols = optionsPage.FilterOutObsoleteSymbols,
SuggestNestedTypes = optionsPage.SuggestNestedTypes,
SuggestTypesOnObjectCreation = optionsPage.SuggestTypesOnObjectCreation,
AddParethesisForNewSuggestions = optionsPage.AddParethesisForNewSuggestions,
SuggestFactoryMethodsOnObjectCreation = optionsPage.SuggestFactoryMethodsOnObjectCreation,
SuggestLocalVariablesFirst = optionsPage.SuggestLocalVariablesFirst
};
}
}
}
2 changes: 1 addition & 1 deletion IntelliSenseExtender/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="IntelliSenseExtender.Dreamescaper.87a2f156-5263-457a-bca9-45f1ca5643ef" Version="0.9.2" Language="en-US" Publisher="Oleksandr Liakhevych (Dreamescaper)" />
<Identity Id="IntelliSenseExtender.Dreamescaper.87a2f156-5263-457a-bca9-45f1ca5643ef" Version="0.9.3" Language="en-US" Publisher="Oleksandr Liakhevych (Dreamescaper)" />
<DisplayName>IntelliSense Extender</DisplayName>
<Description xml:space="preserve">Provide IntelliSense completions not only for imported types, but for all available in current solution and referenced assemblies.</Description>
<MoreInfo>https://github.com/Dreamescaper/IntelliSenseExtender</MoreInfo>
Expand Down
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
0.9.3
+ Fix crash trying to edit file when no solution loaded

0.9.2

+ Fix hang during attributes editing
Expand Down

0 comments on commit 2c8b60d

Please sign in to comment.