-
-
Notifications
You must be signed in to change notification settings - Fork 274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[sheet-] in execCommand(), fail if cmd does not exist #2436
base: develop
Are you sure you want to change the base?
Conversation
776ca06
to
6748b23
Compare
During replay, if a command does not exist, failing is safer than warning. A nonexistent command could be caused by a typo in a user-edited command log, or previously user-defined commands that no longer exist.
6748b23
to
26c3e0b
Compare
For this PR, I needed to make changes to get tests to pass. One test was trying to run commands that couldn't be found. It was running commands on a test The other test that started to fail was the macro test, But then I ran into another problem, which is that macros couldn't be run when Note that there is still one case where macros aren't loaded, which is bare |
26c3e0b
to
d6e255b
Compare
Macros are loaded by run(), which is not called when --batch is given.
d6e255b
to
12b5079
Compare
@@ -194,7 +194,7 @@ def execCommand(self, longname, vdglobals=None, keystrokes=None): | |||
|
|||
cmd = self.getCommand(longname or keystrokes) | |||
if not cmd: | |||
vd.warning('no command for %s' % (longname or keystrokes)) | |||
vd.fail('no command for %s' % (longname or keystrokes)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a vague recollection that fail
was not desired in replay at one time. Maybe it was that some commands would fail
, but you wanted them to continue anyway? Like select-regex
, if nothing matches, you can still delete-selected
as a no-op, but you don't want to abort the replay entirely.
That's almost entirely tangential to this, but it makes me wonder if something like this should be error
instead of fail
? There's almost no difference between them--error is red while fail is yellow. But we could use them more semantically, in case we want to catch fail
s and continue the replay, vs let error
s abort the replay.
Either way, I agree that an unknown command should abort the replay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this, @midichef !
A command that does not exist, like
qqquit-sheet
, will be skipped during replay of a macro or command log, but the subsequent commands will continue to be replayed.Some ways that could happen: a user makes a typo editing a command name in a macro or command log. Or in the past, the user defined a command to be used in a macro, for example,
loggable-quit-sheet
, and now they delete the command definition, breaking the macro that uses it.It seems better to
fail()
instead ofwarning()
in this case. Is there a case wherewarning()
is better?