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

Handle return in ordered lists context #326

Merged
merged 1 commit into from
Sep 21, 2017

Conversation

xgouchet
Copy link
Contributor

This allows to continue an ordered list by pressing return, the same way
unordered lists and quote blocks are handled.

I changed the detection to use a regex that might ease other supports

ReText/editor.py Outdated
# Reset the cursor
cursor = self.textCursor()
cursor.insertText(('\n' + text[:pos]) if pos < length else '\n')
match = re.search("^[\\s]*([*>-]|\\d+\\.) ", text)
Copy link
Member

Choose a reason for hiding this comment

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

Please pre-compile the regexes for performance using re.compile.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done 👍

ReText/editor.py Outdated
if len(matchedText) == length:
cursor.removeSelectedText()
matchedText = ''
else :
Copy link
Member

Choose a reason for hiding this comment

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

Please remove spaces after else.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done 👍

Copy link
Member

Choose a reason for hiding this comment

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

Sorry but here it is not done…

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oups Sorry 'bout that

Copy link
Member

@mitya57 mitya57 left a comment

Choose a reason for hiding this comment

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

Just a couple more nits and I will merge it.

ReText/editor.py Outdated
if len(matchedText) == length:
cursor.removeSelectedText()
matchedText = ''
else :
Copy link
Member

Choose a reason for hiding this comment

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

Sorry but here it is not done…

ReText/editor.py Outdated
@@ -105,6 +105,8 @@ def __init__(self, parent):
self.infoArea = LineInfoArea(self)
self.statistics = (0, 0, 0)
self.statsArea = TextInfoArea(self)
self.returnBlockPattern = re.compile("^[\\s]*([*>-]|\\d+\\.) ")
self.orderedListPattern = re.compile("^([\\s]*)(\\d+)\\. $")
Copy link
Member

Choose a reason for hiding this comment

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

I would move it to class level (below the scrollLimitReached = pyqtSignal(QWheelEvent) line) for even more performance :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done :)

This allows to continue an ordered list by pressing return, the same way
unordered lists and quote blocks are handled.

I changed the detection to use a regex that might ease other supports
@mitya57 mitya57 merged commit 9ea6ca8 into retext-project:master Sep 21, 2017
@mitya57
Copy link
Member

mitya57 commented Sep 21, 2017

Merged. Thanks a lot!

@xgouchet xgouchet deleted the handle_ordered_lists branch September 21, 2017 12:19
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.

None yet

2 participants