Fix logic for repeat commands, so that regex commands (specificially bt) are
given the opportunity to provide a repeat command.
rdar://104562616
Differential D143695
[lldb] Make repeat commands work for regex commands kastiglione on Feb 9 2023, 5:30 PM. Authored by
Details
Fix logic for repeat commands, so that regex commands (specificially bt) are rdar://104562616
Diff Detail
Event TimelineComment Actions This change didn't immediately make sense to me, which means it's a bit tricky and tricky changes should get comments or they will confuse us later on. Plus, I wasn't sure how it worked, so I'm looking forward to reading the comment as part of the review...
Comment Actions So the problem is that regex commands don't want to add the resolved command to the history, and so they need to force the creation of the repeat command even though they aren't adding to the history. But allow_repeat_command is a misleading name for that. It makes is sound like if I don't pass that flag I won't get a repeat command. force_repeat_command would be a better name - you aren't allowing this you're requiring it... And some explanation of why it's necessary would help make this patch understandable. Comment Actions
I agree. I did have some loose thoughts matching this, when writing it, yet somehow ended up with allow_. |
You at least need to fix this comment, since you aren't checking empty_command anymore.
It would also be good to explain the logic here, since I'm not entirely sure why this patch fixes the problem. It should just mean that we are setting the "previous repeat command" twice, once above and once here, in the case where we didn't set "empty_command", so it's not clear why that helps.
I also think it's wrong to set a repeat command when add_to_history is false. That generally happens if some code, like a breakpoint command, uses HandleCommand, i.e. that's a command the user didn't directly execute. So it doesn't make sense that that non-user command should set the user repeat command.