gh-95191: IDLE: Include prompts when saving Shell #95554

This commit is contained in:
Terry Jan Reedy 2022-08-02 00:10:39 -04:00 committed by GitHub
parent d2c1a9c76c
commit b85411fc5e
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