Skip to content

IDLE: usually include prompts when save or copy shell  #95191

Closed
@terryjreedy

Description

@terryjreedy

Up through 3.9, saving the shell saved saved the contents of the underlying text widget, which saved user input with the primary prompt and weird indents. In 3.10, the primary prompt was moved to a sidebar and secondary prompts added, allowing proper indents in the text widget. However, we left File => Save as saving the text widget text, which meant saving without the prompts. Keeping the same implementation changed the result. Prompted by a complaint by Raymond Hettinger, I regard this as a regression whose fix, by including prompts as the default mode of saving, is a high priority.

Saving both input and output without prompts had no precedent and does not seem useful, so I don't plan to keep it as an option. A useful option, already intended, is to save only code and that without prompts, so the saved code can be loaded into an editor. A possible variation would be to include output as comment blocks. Either way, this is a separate issue.

Selecting and copying is a bit trickier. In 3.9, one could select a single statement (and maybe its output) with or without the leading '>>>'. Selecting multiple statements necessarily included any output, uncommented, and prompts after the first. In 3.10, one can select text in the text area, as normal, or select lines in the sidebar with click and drag. Right click offers 2 copy options: 'copy' copies the selection as is; 'copy with prompts' extends any incomplete lines and adds prompts to input lines. Extending the lines makes the selection the same as if it had been done by a sidebar click and drag. (Adding a 'copy code' option, as discussed above, would be part of a separate issue.) I intend to keep both options, but change 'copy' to 'copy as is' or 'copy selection' and put it second.

Currently Edit=>Copy (or its hotkey, such as ^-C) copies as is. For people who select more than just one statement, this is a regression and adding prompts would be much better. When one selects at most one statement, adding a prompt might be surprising and unwanted.

We could split the Edit Copy option into 'Copy with prompts' and 'Copy as is'. (But see below.) If we do, which should get ^-C or current equivalent as hotkey. Adding another hotkey for the other is possible, but somewhat of a pain. Removing it later would be even more painful. (Again, see below.)

@rhettinger If we do not split Edit Copy, which copy option should it do? If we do split it, what should the current copy hotkey do?

I will soon open an issue that could remove the prompt sidebar from the history area and instead insert them into the text widget when a statement is execution. The history area would then look like the executed statement area of the REPL (at least as in Windows Command Prompt). Splitting Edit Copy as proposed above would then be a mistake. I will start with fixing saves.

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.10only security fixes3.11only security fixes3.12only security fixestopic-IDLEtype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions