add showing all commands if prompt is whitespace(s)
This commit is contained in:
@@ -325,12 +325,17 @@ namespace FlaxEditor.Windows
|
||||
|
||||
// Show commands search popup based on current text input
|
||||
var text = Text.Trim();
|
||||
if (text.Length != 0)
|
||||
bool isWhitespaceOnly = string.IsNullOrWhiteSpace(Text) && !string.IsNullOrEmpty(Text);
|
||||
if (text.Length != 0 || isWhitespaceOnly)
|
||||
{
|
||||
DebugCommands.Search(text, out var matches);
|
||||
if (matches.Length != 0)
|
||||
if (matches.Length != 0 || isWhitespaceOnly)
|
||||
{
|
||||
ShowPopup(ref _searchPopup, matches, text);
|
||||
string[] commands = [];
|
||||
if (isWhitespaceOnly)
|
||||
DebugCommands.GetAllCommands(out commands);
|
||||
|
||||
ShowPopup(ref _searchPopup, isWhitespaceOnly ? commands : matches, isWhitespaceOnly ? commands[0] : text);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -435,6 +435,17 @@ void DebugCommands::InitAsync()
|
||||
AsyncTask = Task::StartNew(InitCommands);
|
||||
}
|
||||
|
||||
void DebugCommands::GetAllCommands(Array<StringView>& commands)
|
||||
{
|
||||
EnsureInited();
|
||||
ScopeLock lock(Locker);
|
||||
|
||||
for (auto& command : Commands)
|
||||
{
|
||||
commands.Add(command.Name);
|
||||
}
|
||||
}
|
||||
|
||||
DebugCommands::CommandFlags DebugCommands::GetCommandFlags(StringView command)
|
||||
{
|
||||
CommandFlags result = CommandFlags::None;
|
||||
|
||||
@@ -46,6 +46,13 @@ public:
|
||||
/// </summary>
|
||||
API_FUNCTION() static void InitAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Gets all available commands.
|
||||
/// </summary>
|
||||
/// <param name="matches">The output list of all commands (unsorted).</param>
|
||||
/// <returns>TODO.</returns>
|
||||
API_FUNCTION() static void GetAllCommands(API_PARAM(Out) Array<StringView, HeapAllocation>& commands);
|
||||
|
||||
/// <summary>
|
||||
/// Returns flags of the command.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user