New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-33046: An IDLE option to strip trailing whitespace on save #17201
base: main
Are you sure you want to change the base?
bpo-33046: An IDLE option to strip trailing whitespace on save #17201
Conversation
There are calls to |
I am thinking about the undo issue to make sure I agree. |
Having an item in the undo history is needed, otherwise undoing changes before the whitespace stripping could potentially be broken. I don't really see a way to avoid it. |
@@ -67,6 +67,7 @@ font-size= 10 | |||
font-bold= 0 | |||
encoding= none | |||
line-numbers-default= 0 | |||
strip-trailing-whitespace-on-save= 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rstrip-on-save
might be sufficient.
Except for line-numbers, the other existing items are actually for the base class used for editor, shell, and output windows. This has to be for editor windows only, at least at present. PyShell subclasses code.Interactive Interpreter, which already does some stripping before compiling. And user code output should not be touched. This different between items should somehow be more obvious on the configdialog tab. I am thinking about what to do.
If someone want to disable this, doing so for particular windows makes more sense than globally. Could we get away with having only a window option, or are there really people who would never want
@@ -371,6 +371,11 @@ def save_a_copy(self, event): | |||
return "break" | |||
|
|||
def writefile(self, filename): | |||
strip = idleConf.GetOption( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If rstrip_save is a per-window property, this will not work.
'main', 'EditorWindow', | ||
'strip-trailing-whitespace-on-save', type='bool') | ||
if strip: | ||
self.editwin.Rstrip(self.editwin).do_rstrip() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is already a per-window event handler which I believe could be reused.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
On undo, I will go with what Tal says until an actual problem becomes evident. |
@ZackerySpytz, please address the code review. Thanks! |
Ping, @ZackerySpytz? |
https://bugs.python.org/issue33046