-
Notifications
You must be signed in to change notification settings - Fork 136
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
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
be49cb2
ignore first pac command if there are two consecutive pac commands
OlteanuRares 8a5661c
add a test
OlteanuRares 7d758a2
change method name and extract unhandled commands into constamt
OlteanuRares 5b990fc
merged main and change the skipping logic
OlteanuRares 32bf95b
change the skip logic for offset commands
OlteanuRares 94461d1
remove leftovers
OlteanuRares f2cd7c0
fix converter test
OlteanuRares 6c90c4b
merge main and fix conflicts
OlteanuRares 1b8f6be
bump version to 2.2.5.dev
OlteanuRares File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -342,10 +342,9 @@ def interpret_command(self, command): | |
|
||
:type command: str | ||
""" | ||
self._update_positioning(command) | ||
|
||
if command not in ["9120", "91ae", "912f", "91a1"]: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
self._update_positioning(command) | ||
text = COMMANDS.get(command, '') | ||
|
||
if 'italic' in text: | ||
if 'end' not in text: | ||
self._collection.append( | ||
|
@@ -365,11 +364,13 @@ def _update_positioning(self, command): | |
|
||
:type command: str | ||
""" | ||
|
||
if command in PAC_TAB_OFFSET_COMMANDS: | ||
tab_offset = PAC_TAB_OFFSET_COMMANDS[command] | ||
prev_positioning = self._position_tracer.default | ||
positioning = (prev_positioning[0], | ||
prev_positioning[1] + tab_offset) | ||
|
||
else: | ||
first, second = command[:2], command[2:] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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