Accept special commands without trailing semicolons even in multi-line mode#1545
Conversation
even in multi-line mode. "exit" was always an exception to the multi-line trailing semicolon rule. At minimum, "help" should likewise be an exception. This makes all special commands exceptions to the multi-line trailing semicolon requirement, on the theory of consistency, because special commands starting with backslash have also always been exceptions.
| # Exit doesn't need semi-column` | ||
| (text == "exit") | ||
| # non-backslashed special commands such as "exit" or "help" don't need semicolon | ||
| first_word in SPECIAL_COMMANDS |
There was a problem hiding this comment.
Since first_word seems to come in as-is (could be mixed case), I'd either change this first one to .upper() or just combine the two cases and have it be something like first_word.lower() in (key.lower() for key in SPECIAL_COMMANDS.keys())` to cover both cases maybe.
There was a problem hiding this comment.
I'm failing to understand the suggestion. By the time we get here, the words are only the textual forms, because the backslash forms were handled above. So we should only need to account for accepting eg EXIT like exit. If this is wrong we can follow up.
There was a problem hiding this comment.
It's not wrong, I just think you could get rid of the first condition. You're currently checking if the as-is value is in special commands, and then you check if the lowercase version is in special commands. So you really only need to check the lowercase value as that will cover both situations (user gives EXIT or exit), or ExiT, or whatever).
scottnemes
left a comment
There was a problem hiding this comment.
Approving as-is, left a comment if for potential update if desired.
Description
"exit" was always an exception to the multi-line trailing semicolon rule. At minimum, "help" should likewise be an exception.
This makes all special commands exceptions to the multi-line trailing semicolon requirement, on the theory of consistency, because special commands starting with backslash have also always been exceptions.
Tests seem difficult. We'd want to do a "behave" test using an alternate configuration.
Checklist
changelog.mdfile.AUTHORSfile (or it's already there).