This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: PyShell.recall - fix indentation logic
Type: Stage:
Components: IDLE Versions:
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: kbk Nosy List: kbk, taleinat
Priority: high Keywords: patch

Created on 2006-07-25 16:07 by taleinat, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
IDLE_PyShell_recall.patch taleinat, 2006-07-27 20:48 initial patch
IDLE_PyShell_recall.patch taleinat, 2006-07-30 12:06 update
Messages (6)
msg50755 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2006-07-25 16:07
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%.
msg50756 - (view) Author: Kurt B. Kaiser (kbk) * (Python committer) Date: 2006-07-26 20:30
Logged In: YES 
user_id=149084

Well, once you get it throughly tested, please
attach the patch so I can look at it.
msg50757 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2006-07-27 20:48
Logged In: YES 
user_id=1330769

Bah, sorry for forgetting to post the file... It really was
getting late that night :P
msg50758 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2006-07-30 12:06
Logged In: YES 
user_id=1330769

I uploaded an update (another patch, apply after applying
the first one), this fixes the behavior a bit.
msg50759 - (view) Author: Kurt B. Kaiser (kbk) * (Python committer) Date: 2006-08-10 17:14
Logged In: YES 
user_id=149084

2.5b3 Rev 51189.  Thanks for the patch!
msg50760 - (view) Author: Kurt B. Kaiser (kbk) * (Python committer) Date: 2006-08-14 14:14
Logged In: YES 
user_id=149084

2.5b3 Rev 51189.  Thanks for the patch!
History
Date User Action Args
2022-04-11 14:56:19adminsetgithub: 43719
2006-07-25 16:07:02taleinatcreate