Phil Webster added the comment:

I've attached a patch that attempts to address the issues above. For the tests, 
I made some changes because the cursor doesn't end in exactly the same spot 
with line endings.

Here's a quick summary of the changes:
1. Removed format_paragraph and format_comment methods because all text is 
treated the same and formatted in the event method. (The formatting code could 
be pulled out of the format_event method if needed.)

2. Added find_string_indices method to see if cursor is in string using the 
text widget's string tag. If the cursor is in a string, only the string lines 
are formatted. Before, if code immediately preceded or followed the string at 
the same indentation level, it was treated as part of the same paragraph.

3. If the text to be formatted ends with a triple quoted string on its own line 
(such as a docstring), the formatting code leaves the line alone.

4. If selection contains multiple paragraphs (separated by blank lines), it can 
format each one. Previously, only the first paragraph was formatted.

Once I have some feedback, I can thoroughly check all of the tests and make 
sure that we're getting the expected behavior.

----------
keywords: +patch
Added file: http://bugs.python.org/file31266/18583enhancefp1.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue18583>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to