mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
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:
parent
118851b8ba
commit
8570f6d1a0
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