Skip to content
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

Fix map netId completions #5495

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 6 additions & 4 deletions Robust.Shared/Console/CompletionHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using JetBrains.Annotations;
Expand Down Expand Up @@ -186,15 +186,17 @@ public static IEnumerable<CompletionOption> MapIds(IEntityManager? entManager =

public static IEnumerable<CompletionOption> MapUids(IEntityManager? entManager = null)
{
return Components<MapComponent>(string.Empty, entManager);
IoCManager.Resolve(ref entManager);

return Components<MapComponent>(string.Empty, entManager, limit: int.MaxValue); // faster just to pass the max value than bother unlimiting it.
}

Comment on lines +190 to 192
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least it make it like 100 or something if you want higher than 20.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if you have more than 100 maps it just wont work as expected.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The limit only applies to matching uids, so as you start typing the uid it would still eventually show the completions for the map you want, even if there are far more than 20 maps. It only really matters if you really want to get given the completion tooltip with 100+ maps that you want to manually read through to find the right uid.

Though TBH I'm not even sure if having the limit implemented like that is really of any use. Even with it there, the helper should still only ever be used when you know there's only going to be a handful of components. Calling with with something like TransformComponent could still result in it iterating over almost all entities . E.g., in my toolshed PR I just arbitrarily limited it to EntityManager.Count<TComp>() <= 128

/// <summary>
/// Return all existing entities as possible completions. You should generally avoid using this unless you need to.
/// </summary>
public static IEnumerable<CompletionOption> NetEntities(string text, IEntityManager? entManager = null, int limit = 20)
{
if (!NetEntity.TryParse(text, out _))
if (text != string.Empty && !NetEntity.TryParse(text, out _))
yield break;

IoCManager.Resolve(ref entManager);
Expand All @@ -214,7 +216,7 @@ public static IEnumerable<CompletionOption> NetEntities(string text, IEntityMana

public static IEnumerable<CompletionOption> Components<T>(string text, IEntityManager? entManager = null, int limit = 20) where T : IComponent
{
if (!NetEntity.TryParse(text, out _))
if (text != string.Empty && !NetEntity.TryParse(text, out _))
yield break;

IoCManager.Resolve(ref entManager);
Expand Down
Loading