summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/FormatParagraph.py
diff options
context:
space:
mode:
authorTerry Jan Reedy <tjreedy@udel.edu>2014-04-22 05:11:03 (GMT)
committerTerry Jan Reedy <tjreedy@udel.edu>2014-04-22 05:11:03 (GMT)
commitd5d4c4eabe00186e9c9020bc6caa045784ee3cc9 (patch)
tree75ad8bd6a28bbc40bc1f5b040ef041f55f17e3ac /Lib/idlelib/FormatParagraph.py
parent4a63923328650bb73f40bcec5bb06ebbd409811d (diff)
downloadcpython-d5d4c4eabe00186e9c9020bc6caa045784ee3cc9.zip
cpython-d5d4c4eabe00186e9c9020bc6caa045784ee3cc9.tar.gz
cpython-d5d4c4eabe00186e9c9020bc6caa045784ee3cc9.tar.bz2
Issue 21284: Idle: make test_formatparagraph pass even when a user changes the
reformat width in the configuration menu.
Diffstat (limited to 'Lib/idlelib/FormatParagraph.py')
-rw-r--r--Lib/idlelib/FormatParagraph.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/Lib/idlelib/FormatParagraph.py b/Lib/idlelib/FormatParagraph.py
index ae4e6e7..2ac87e4 100644
--- a/Lib/idlelib/FormatParagraph.py
+++ b/Lib/idlelib/FormatParagraph.py
@@ -32,7 +32,7 @@ class FormatParagraph:
def close(self):
self.editwin = None
- def format_paragraph_event(self, event):
+ def format_paragraph_event(self, event, limit=None):
"""Formats paragraph to a max width specified in idleConf.
If text is selected, format_paragraph_event will start breaking lines
@@ -41,9 +41,12 @@ class FormatParagraph:
If no text is selected, format_paragraph_event uses the current
cursor location to determine the paragraph (lines of text surrounded
by blank lines) and formats it.
+
+ The length limit parameter is for testing with a known value.
"""
- maxformatwidth = idleConf.GetOption(
- 'main', 'FormatParagraph', 'paragraph', type='int')
+ if limit == None:
+ limit = idleConf.GetOption(
+ 'main', 'FormatParagraph', 'paragraph', type='int')
text = self.editwin.text
first, last = self.editwin.get_selection_indices()
if first and last:
@@ -53,9 +56,9 @@ class FormatParagraph:
first, last, comment_header, data = \
find_paragraph(text, text.index("insert"))
if comment_header:
- newdata = reformat_comment(data, maxformatwidth, comment_header)
+ newdata = reformat_comment(data, limit, comment_header)
else:
- newdata = reformat_paragraph(data, maxformatwidth)
+ newdata = reformat_paragraph(data, limit)
text.tag_remove("sel", "1.0", "end")
if newdata != data: