Repository: evennia/evennia

Issue:
[DEVEL][BUG] Multi-match command doesn't pass args
#### Describe the bug
When presented with and resolving a command multi-match prompt, arguments are not passed in correctly.

#### To Reproduce
Steps to reproduce the behavior:
1. Create `testobjs.py` in the `typeclasses` folder:
```python
from typeclasses.objects import Object
from commands.command import Command
from evennia import CmdSet


class CmdSmash(Command):
    """
    Smash an object!

    Usage:
      smash <obj>
    """
    key = "smash"
    help_category = "TestObj"

    def func(self):
        caller = self.caller

        if not self.args:
            caller.msg("Smash what?")
            return

        target = caller.search(self.args.strip())

        if target:
            if target is self.obj:
                if target.tags.get("smashed", category="testobj"):
                    caller.msg("A %s has already been smashed!" % target.key)
                    return
                caller.msg("You smash the %s." % target.key)
                self.obj.tags.add("smashed", category="testobj")
            else:
                caller.msg("You are not able to smash %s." % target.key)


class TestObjCmdSet(CmdSet):
    key = "TestObjCmdSet"

    def at_cmdset_creation(self):
        self.add(CmdSmash())


class TestObj(Object):
    """
    A test object for us to play with!
    """

    def at_object_creation(self):
        self.db.desc = "This is a small test object for testing things."
        self.cmdset.add(TestObjCmdSet, persistent=True)

    def return_appearance(self, looker):
        msg = super().return_appearance(looker)
        if self.tags.get("smashed", category="testobj"):
            msg += "\nIt has been smashed to bits!"
        return msg
```
2. In game, type `create/drop test:typeclasses.testobjs.TestObj` to create a test object containing the **smash** command.
3. Type `smash`. Observe the message: `Smash what?`. Next type `smash test`. Observe the message: `You smash test.`
4. Type `create/drop test:typeclasses.testobjs.TestObj` to create a second test object.
5. Type `smash`. Observe the multi-match prompt.
6. **ERROR:** Type `smash-1 test`. Observe that it does not work as intended: `Smash what?`. The argument is no longer being passed properly in the command.

#### Expected behavior
After manually resolving the multi-match error by selecting smash-1 or smash-2, the command should work as intended when passing in the proper arguments.

#### Environment, Evennia version, OS etc
Evennia version: 1.0-dev (rev 287a76921)
OS: posix
Python: 3.8.10
Twisted: 20.3.0
Django: 3.2.6



Discussion:
It looks as though the regex `(?P<name>.*)-(?P<number>[0-9]+)` and the code at `cmdparser.py line 123-128` is responsible for dropping the args.
After a bit more investigation and tinkering, I think I solved the problem by changing the MULTIMATCH_REGEX to:
`(?P<name>[^-]*)-(?P<number>[0-9]+)(?P<args>.*)` 

and changing the code at cmdparser.py line 128 to:
`mindex, new_raw_string = (num_ref_match.group("number"), num_ref_match.group("name") + num_ref_match.group("args"))`

@Griatch do you believe this is a viable solution?
@Qaishin Thanks for the investigation and example code! I'm not wholly convinced by your solution because you are just catching everything at the end but I'd need to run the the code to see if I can reproduce before I can judge :) 
Related: #2431

Resolving patch:
diff --git a/evennia/commands/cmdparser.py b/evennia/commands/cmdparser.py
--- a/evennia/commands/cmdparser.py
+++ b/evennia/commands/cmdparser.py
@@ -125,7 +125,7 @@ def try_num_differentiators(raw_string):
         # the user might be trying to identify the command
         # with a #num-command style syntax. We expect the regex to
         # contain the groups "number" and "name".
-        mindex, new_raw_string = (num_ref_match.group("number"), num_ref_match.group("name"))
+        mindex, new_raw_string = (num_ref_match.group("number"), num_ref_match.group("name") + num_ref_match.group("args"))
         return int(mindex), new_raw_string
     else:
         return None, None
diff --git a/evennia/settings_default.py b/evennia/settings_default.py
--- a/evennia/settings_default.py
+++ b/evennia/settings_default.py
@@ -324,7 +324,7 @@
 # parser expects this. It should also involve a number starting from 1.
 # When changing this you must also update SEARCH_MULTIMATCH_TEMPLATE
 # to properly describe the syntax.
-SEARCH_MULTIMATCH_REGEX = r"(?P<name>.*)-(?P<number>[0-9]+)"
+SEARCH_MULTIMATCH_REGEX = r"(?P<name>[^-]*)-(?P<number>[0-9]+)(?P<args>.*)"
 # To display multimatch errors in various listings we must display
 # the syntax in a way that matches what SEARCH_MULTIMATCH_REGEX understand.
 # The template will be populated with data and expects the following markup:


Test patch: