Fix handling of custom commands with spaces - the shortest valid prefix of the arguments was being handled instead of the longest