[Patches] [ python-Patches-1528468 ] PyShell.recall - fix indentation logic

SourceForge.net noreply at sourceforge.net
Wed Jul 26 22:30:48 CEST 2006


Patches item #1528468, was opened at 2006-07-25 12:07
Message generated for change (Comment added) made by kbk
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1528468&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: IDLE
Group: None
Status: Open
>Resolution: Later
Priority: 3
Submitted By: Tal Einat (taleinat)
Assigned to: Nobody/Anonymous (nobody)
Summary: PyShell.recall - fix indentation logic

Initial Comment:
PyShell.recall uses wrong indentation logic when
recalling a block of code (more than one line).

It first inserts the first line and calls
newline_and_indent, which inserts a newline and indents
the next line according to heuristics - more indent
after ':', less after a return, etc. So far so good.

Afterwards, for each following line, it just inserts
line.strip(), and again calls newline_and_indent. This
often ruins the block's indentation, for instance at
the end of loops and 'if' blocks.

This can easily be improved upon since we have the
original indentation. This patch retains the block's
original indentation, only adjusting it to fit the
current base indentation level.

This patch also doesn't add an extra newline at the end
of a recalled block, unless there was on there originally.

I haven't tested it thoroughly but I have played around
with it a lot and tweaked it. So far it seems to work 100%.

----------------------------------------------------------------------

>Comment By: Kurt B. Kaiser (kbk)
Date: 2006-07-26 16:30

Message:
Logged In: YES 
user_id=149084

Well, once you get it throughly tested, please
attach the patch so I can look at it.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1528468&group_id=5470


More information about the Patches mailing list