diff options
author | Kurt B. Kaiser <kbk@shore.net> | 2002-12-29 22:03:38 (GMT) |
---|---|---|
committer | Kurt B. Kaiser <kbk@shore.net> | 2002-12-29 22:03:38 (GMT) |
commit | 4ada7ad3bc9ab269189ed20e57943d9721664deb (patch) | |
tree | 327c3d149a6902106b4d476284c854d439693d69 /Lib/idlelib/EditorWindow.py | |
parent | af72d5221f6c826c05594cb1877e8b6d6e20d12b (diff) | |
download | cpython-4ada7ad3bc9ab269189ed20e57943d9721664deb.zip cpython-4ada7ad3bc9ab269189ed20e57943d9721664deb.tar.gz cpython-4ada7ad3bc9ab269189ed20e57943d9721664deb.tar.bz2 |
M EditorWindow.py
M PyShell.py
1. PyShell Rev 1.39, EditorWindow Rev 1.37 fix was not handling a
multiline prompt.
2. The same fix introduced a bug where hitting <enter> at a previous
prompt-only line would copy the prompt to the iomark.
3. Move the setting of sys.ps1 earlier, into PyShell.main(), to allow
this code to work before a shell is started up.
4. If cursor is on the input line in the prompt, and you hit <enter>,
process the line instead of complaining.
5. If line has no stdin range (this includes the last line before shell
restart) strip any prompt before recalling.
Diffstat (limited to 'Lib/idlelib/EditorWindow.py')
-rw-r--r-- | Lib/idlelib/EditorWindow.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py index 5719352..f039503 100644 --- a/Lib/idlelib/EditorWindow.py +++ b/Lib/idlelib/EditorWindow.py @@ -952,9 +952,11 @@ class EditorWindow: have = len(chars.expandtabs(tabwidth)) assert have > 0 want = ((have - 1) // self.indentwidth) * self.indentwidth + # Debug prompt is multilined.... + last_line_of_prompt = sys.ps1.split('\n')[-1] ncharsdeleted = 0 while 1: - if chars == sys.ps1: + if chars == last_line_of_prompt: break chars = chars[:-1] ncharsdeleted = ncharsdeleted + 1 @@ -1011,19 +1013,18 @@ class EditorWindow: text.mark_set("insert", first) line = text.get("insert linestart", "insert") i, n = 0, len(line) - if line == sys.ps1: - return "break" while i < n and line[i] in " \t": i = i+1 if i == n: - # the cursor is in or at leading indentation; just inject - # an empty line at the start + # the cursor is in or at leading indentation in a continuation + # line; just inject an empty line at the start text.insert("insert linestart", '\n') return "break" indent = line[:i] - # strip whitespace before insert point + # strip whitespace before insert point unless it's in the prompt i = 0 - while line and line[-1] in " \t": + last_line_of_prompt = sys.ps1.split('\n')[-1] + while line and line[-1] in " \t" and line != last_line_of_prompt: line = line[:-1] i = i+1 if i: |