aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/idlelib/FormatParagraph.py
diff options
context:
space:
mode:
authorAndrew Svetlov <andrew.svetlov@gmail.com>2012-12-24 13:17:11 +0200
committerAndrew Svetlov <andrew.svetlov@gmail.com>2012-12-24 13:17:11 +0200
commit6a7a49c6318afe8a54fe6dda2dd321af2a275295 (patch)
treedc40e0c191d6688ef0b27531f177c7f9afe31997 /Lib/idlelib/FormatParagraph.py
parent7d2fad1be2cb5f02f5dd2940c5e1fdd9cb3659af (diff)
parent7174f0883cde6295ae5cc8797bab63f69ca550e3 (diff)
downloadcpython-6a7a49c6318afe8a54fe6dda2dd321af2a275295.tar.gz
cpython-6a7a49c6318afe8a54fe6dda2dd321af2a275295.zip
Issue #16511: Use default IDLE width and height if config param is not valid.
Patch Serhiy Storchaka.
Diffstat (limited to 'Lib/idlelib/FormatParagraph.py')
-rw-r--r--Lib/idlelib/FormatParagraph.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/idlelib/FormatParagraph.py b/Lib/idlelib/FormatParagraph.py
index 6a5f9b5dd59..e3ca7b9b3d4 100644
--- a/Lib/idlelib/FormatParagraph.py
+++ b/Lib/idlelib/FormatParagraph.py
@@ -32,7 +32,8 @@ class FormatParagraph:
self.editwin = None
def format_paragraph_event(self, event):
- maxformatwidth = int(idleConf.GetOption('main','FormatParagraph','paragraph'))
+ maxformatwidth = int(idleConf.GetOption('main', 'FormatParagraph',
+ 'paragraph', type='int'))
text = self.editwin.text
first, last = self.editwin.get_selection_indices()
if first and last:
@@ -46,7 +47,8 @@ class FormatParagraph:
lines = data.split("\n")
lines = map(lambda st, l=len(comment_header): st[l:], lines)
data = "\n".join(lines)
- # Reformat to maxformatwidth chars or a 20 char width, whichever is greater.
+ # Reformat to maxformatwidth chars or a 20 char width,
+ # whichever is greater.
format_width = max(maxformatwidth - len(comment_header), 20)
newdata = reformat_paragraph(data, format_width)
# re-split and re-insert the comment header.