diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 0764eee5359..751592f28bc 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -39,7 +39,7 @@ END TEMPLATE--> ### New features -*None yet* +* Console completion options now have a new flags for preventing suggestions from being escaped or quoted. ### Bugfixes diff --git a/Robust.Client/UserInterface/CustomControls/DebugConsole.xaml.Completions.cs b/Robust.Client/UserInterface/CustomControls/DebugConsole.xaml.Completions.cs index 0bfd2c43254..77774c5f70b 100644 --- a/Robust.Client/UserInterface/CustomControls/DebugConsole.xaml.Completions.cs +++ b/Robust.Client/UserInterface/CustomControls/DebugConsole.xaml.Completions.cs @@ -276,10 +276,14 @@ private void CompletionKeyDown(GUIBoundKeyEventArgs args) // This means that letter casing will match the completion suggestion. CommandBar.CursorPosition = lastRange.end; CommandBar.SelectionStart = lastRange.start; - var insertValue = CommandParsing.Escape(completion); + + var insertValue = (completionFlags & CompletionOptionFlags.NoEscape) == 0 + ? CommandParsing.Escape(completion) + : completion; // If the replacement contains a space, we must quote it to treat it as a single argument. - var mustQuote = insertValue.Contains(' '); + var mustQuote = (completionFlags & CompletionOptionFlags.NoQuote) == 0 && insertValue.Contains(' '); + if ((completionFlags & CompletionOptionFlags.PartialCompletion) == 0) { if (mustQuote) diff --git a/Robust.Shared/Console/CompletionResult.cs b/Robust.Shared/Console/CompletionResult.cs index 8be56daada1..11920f2283e 100644 --- a/Robust.Shared/Console/CompletionResult.cs +++ b/Robust.Shared/Console/CompletionResult.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Robust.Shared.Utility; namespace Robust.Shared.Console; @@ -74,4 +75,14 @@ public enum CompletionOptionFlags /// (instead of adding a space to go to the next one). /// PartialCompletion = 1 << 0, + + /// + /// Prevents suggestions containing spaces from being automatically wrapped in quotes. + /// + NoQuote = 1 << 1, + + /// + /// Prevents suggestions from being escaped using . + /// + NoEscape = 1 << 2, } diff --git a/Robust.Shared/Toolshed/TypeParsers/StringTypeParser.cs b/Robust.Shared/Toolshed/TypeParsers/StringTypeParser.cs index dedfa213296..6f5c8d4b57b 100644 --- a/Robust.Shared/Toolshed/TypeParsers/StringTypeParser.cs +++ b/Robust.Shared/Toolshed/TypeParsers/StringTypeParser.cs @@ -11,8 +11,8 @@ namespace Robust.Shared.Toolshed.TypeParsers; internal sealed class StringTypeParser : TypeParser { - // Completion option for hinting that all strings must start with an quote - private static readonly CompletionOption[] Option = [new("\"", Flags: CompletionOptionFlags.PartialCompletion)]; + // Completion option for hinting that all strings must start with a quote + private static readonly CompletionOption[] Option = [new("\"", Flags: CompletionOptionFlags.PartialCompletion | CompletionOptionFlags.NoEscape)]; public override bool TryParse(ParserContext ctx, [NotNullWhen(true)] out string? result) {