gh-95191: IDLE: Include prompts when saving Shell GH-95554 (#95557)

(cherry picked from commit b85411fc5e)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
This commit is contained in:
Miss Islington (bot) 2022-08-01 23:14:19 -07:00 committed by GitHub
parent 118851b8ba
commit 8570f6d1a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 43 additions and 24 deletions

View file

@ -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