Skip to content
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

ignore first pac command if there are two consecutive pac commands #314

Merged
merged 9 commits into from
Feb 20, 2024

Conversation

OlteanuRares
Copy link
Contributor

No description provided.

@OlteanuRares OlteanuRares requested a review from a team as a code owner November 16, 2023 15:19
@@ -327,6 +327,9 @@ def _handle_double_command(self, word):
if word == self.last_command:
self.last_command = ''
return True
elif _is_pac_command(word) and _is_pac_command(self.last_command):
Copy link
Contributor

@ana-nichifor ana-nichifor Nov 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic was used to ignore the second duplicate command, not the first as it seems to be your intention (I saw you wrote a test called test_skip_first_pac_command).

You go with the first command, it doesn’t find a previous double (last_command=‘’) so it returns False (as in the command is NOT a double) and it gets processed. This command is saved as last_command to be used as comparison for the next one.
Then the second command comes, it is compared to the first one (last_command=‘previousword’), it is identified as a double, (last command is being reset to avoid ignoring multiple commands) return True (the command IS a double) and doesn’t get processed.

I realise now that a better name for this would have been _is_double_command or _skip_command for it to be easier to understand

@@ -342,10 +342,9 @@ def interpret_command(self, command):

:type command: str
"""
self._update_positioning(command)

if command not in ["9120", "91ae", "912f", "91a1"]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This list could be stored in a constant to be more suggestive of what it represents, you might not remember its purpose when coming back here after a while

@OlteanuRares OlteanuRares merged commit ed81ae9 into main Feb 20, 2024
13 checks passed
OlteanuRares added a commit that referenced this pull request Feb 22, 2024
…and-sent"

This reverts commit ed81ae9, reversing
changes made to 50b9aa1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants