Skip to content

Commit

Permalink
fix bug that always showed global class names.
Browse files Browse the repository at this point in the history
  • Loading branch information
hecomi committed Nov 29, 2017
1 parent 29bfe39 commit 358bbc2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
Binary file modified Assets/uREPL/Resources/uREPL/Prefabs/uREPL.prefab
Binary file not shown.
20 changes: 11 additions & 9 deletions Assets/uREPL/Scripts/Completions/GlobalClassCompletion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ public class GlobalClassCompletion : CompletionPlugin

protected override void OnEnable()
{
if (globalClassNames_ == null) {
globalClassNames_ = System.AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(asm => asm.GetTypes())
.Where(type => type.IsClass && type.Namespace == null)
.Select(type => type.Name)
.Where(name => char.IsLetter(name[0]))
.Distinct()
.OrderBy(name => name[0])
.ToArray();
if (globalClassNames_ == null) {
globalClassNames_ = System.AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(asm => asm.GetTypes())
.Where(type => type.IsClass && type.Namespace == null)
.Select(type => type.Name)
.Where(name => char.IsLetter(name[0]))
.Distinct()
.OrderBy(name => name[0])
.ToArray();
}

base.OnEnable();
Expand All @@ -28,6 +28,8 @@ public override CompletionInfo[] GetCompletions(string input)
{
var parts = input.Split(new char[] { '\n', ' ', '\t', '=', '{', '}', '(', ')', '<', '>' });
var lastPart = parts.Last();
if (string.IsNullOrEmpty(lastPart)) return null;

return globalClassNames_
.Where(name => name.IndexOf(lastPart) == 0)
.Select(name => new CompletionInfo(
Expand Down
4 changes: 3 additions & 1 deletion Assets/uREPL/Scripts/Completions/MonoCompletion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private CompletionInfo[] GetCustomCompletions(string input, string codeAddedPrev
int index = 0;

// split by '=, \s'
var inputParts = input.Split(new char[] { '=', ' ', ' ' });
var inputParts = input.Split(new char[] { '=', ' ', ' ' }, StringSplitOptions.None);
input = inputParts.Last();

// completion inner block
Expand Down Expand Up @@ -127,6 +127,8 @@ private CompletionInfo[] GetCustomCompletions(string input, string codeAddedPrev
isComplemented = true;
}

if (string.IsNullOrEmpty(prefix)) return null;

return ConvertToCompletionInfoArray(result, prefix);
}

Expand Down
2 changes: 1 addition & 1 deletion Assets/uREPL/Scripts/Gui/Window/KeyBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public void Update()
{
ToggleWindowByKeys();

if (window_.isOpen) {
if (window_ && window_.isOpen) {
if (inputField.isFocused) {
keyEvent_.Check();
} else {
Expand Down

0 comments on commit 358bbc2

Please sign in to comment.