mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-95191: IDLE: Include prompts when saving Shell #95554
This commit is contained in:
parent
d2c1a9c76c
commit
b85411fc5e
5 changed files with 43 additions and 24 deletions
|
@ -251,11 +251,17 @@ class IOBinding:
|
|||
return False
|
||||
|
||||
def fixnewlines(self):
|
||||
"Return text with final \n if needed and os eols."
|
||||
if (self.text.get("end-2c") != '\n'
|
||||
and not hasattr(self.editwin, "interp")): # Not shell.
|
||||
self.text.insert("end-1c", "\n")
|
||||
text = self.text.get("1.0", "end-1c")
|
||||
"""Return text with os eols.
|
||||
|
||||
Add prompts if shell else final \n if missing.
|
||||
"""
|
||||
|
||||
if hasattr(self.editwin, "interp"): # Saving shell.
|
||||
text = self.editwin.get_prompt_text('1.0', self.text.index('end-1c'))
|
||||
else:
|
||||
if self.text.get("end-2c") != '\n':
|
||||
self.text.insert("end-1c", "\n") # Changes 'end-1c' value.
|
||||
text = self.text.get('1.0', "end-1c")
|
||||
if self.eol_convention != "\n":
|
||||
text = text.replace("\n", self.eol_convention)
|
||||
return text
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue