[issue36390] IDLE: Refactor formatting methods from editor

Cheryl Sabella report at bugs.python.org
Thu Mar 21 08:57:58 EDT 2019


Cheryl Sabella <cheryl.sabella at gmail.com> added the comment:

Refactoring the methods was relatively straight forward, but I did have some questions:

1.  The name `formatregion` could probably be improved.
2.  The `classifyws` method is a module level method in editor.  It's needed in `formatregion` also, so I made a copy (bad!).  I would have liked to create a `utils.py` for this, but maybe there's a better place for it?  It doesn't just operate on text widgets as it is just a string function.  I'm sure there's an obvious choice that I'm missing.  See also #4 below.
3.  `tabwidth` and `indentwidth` in `formatregion` are getting the values from the editor window.  I thought about adding those to the init for FormatRegion, but then they would need to be updated if config changed.  Not sure which way would be better.
4.  Other methods in editor might be candidates for moving, such as the auto-indent methods (search on `### begin autoindent code ###` in editor) and specifically `smart_indent_event`.  Moving more of the indent code to a separate module helps with #2 and #3 above, but I wasn't sure how much of the text formatting should be moved.  I thought it best to start with the minimal change.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36390>
_______________________________________


More information about the Python-bugs-list mailing list