mu-editor / mu

A small, simple editor for beginner Python programmers. Written in Python and Qt5.
http://codewith.mu
GNU General Public License v3.0
1.39k stars 432 forks source link

Fix code duplication issue in mu/logic.py #2481

Closed SurajSanap closed 6 months ago

SurajSanap commented 6 months ago

This pull request addresses the issue #2445, which involves refactoring duplicate code in the save method of the mu/logic.py file.

Changes Made:

Refactored the save method to eliminate duplicated code. Introduced a helper function, handle_unsaved_file, to encapsulate the logic for handling unsaved files and checking for shadow modules. Improved code readability and maintainability. Testing Done:

Tested the changes by running existing test cases and performing manual testing. Ensured that the refactored code functions as expected in various scenarios.

Closes #2445

carlosperate commented 6 months ago

Hi @SurajSanap, Not sure I see the code duplication removed in the PR, should handle_unsaved_file() be called somewhere else as well?

carlosperate commented 6 months ago

Hi @SurajSanap, sorry I didn't mean to discourage you, your contribution is appreciated!

I was mostly wondering if wrapping that code in the handle_unsaved_file() function meant there could be another place in the code where we could remove the duplication and call that function instead.