-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
PR: More autoindentation fixes #4082
Conversation
self.textCursor().beginEditBlock() | ||
TextEditBaseWidget.keyPressEvent(self, event) | ||
self.fix_indent(comment_or_string=cmt_or_str) |
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.
The problem with deactivating this is that indentation would become active when you're working inside block comments. That's why I added this.
Instead we should be smarter and check if the line doesn't start with a comment and ends with it one to apply indentation in that case.
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.
Oh I see, then I'll add an extra check for detecting inline comments.
indentation - Fix error with inline comments, and strings
7c6e2c7
to
d8fce0e
Compare
d8fce0e
to
362d896
Compare
This is ready 😄 Should we open a new issue for |
Yes, please do it, assign it to yourself and set it for 3.2. Don't worry about the test failures. I'm working hard to make them more reliable (I'm almost there ;-) |
be3dde4
to
01373f0
Compare
@@ -1979,15 +1979,43 @@ def fix_indent(self, forward=True, comment_or_string=False): | |||
(prevtext.strip().startswith("return") and | |||
len(re.split(r'\(|\{|\[', prevtext)) == | |||
len(re.split(r'\)|\}|\]', prevtext)))): | |||
print("hola2") |
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.
Remove this print
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.
🙈
01373f0
to
d566534
Compare
Great work @rlaverde! This solves all autoindentation issues reported by our users in 3.1 :-) I simply pushed a commit to add some comments and fix column width of some lines. |
pytest.mark.xfail( | ||
("foo = 1 # Comment open parenthesis (\n", | ||
"foo = 1 # Comment open parenthesis (\n", | ||
"test_comment_with parenthesis")), |
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.
Could we solve this one for 3.1.4?
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 mean, it doesn't seem that hard to address :-)
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.
Yes, although this case of use is very rare, I was thinking address it in the rewrite for 3.2
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.
Ok, even better :-)
They time out frequently on Appveyor
Fixes #4096
Fixes #4074
I fixed some issues reported applying hanging indent for long text only