-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
PR: Fix syncing IPython console cwd with the Working directory toolbar #19068
Conversation
Also restore previous set_working_directory method in its main widget. That method really sets the cwd when called and it's declared as part of the console's API.
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.
Thanks @ccordoba12 ! Checking locally seems like there is an odd behavior when opening a project. Seems like the working directory is not being updated and then any new consoles start with the previous working directory that was set before opening the project:
Also, when closing the project the working directory still references the project path but then the new console cwd is not set to be the last path but the default user directory?:
- Those are created not only when Spyder is started but also when opening/closing projects. - Expand tests to check that cwd is synced when opening/closing projects.
7a807f1
to
5de8c91
Compare
Thanks for checking those cases @dalthviz! I think I fixed them in my last commit, in which I also expanded the new tests I added to cover them. |
Thanks for the changes @ccordoba12 ! Seems like the first part is fixed However, the last part (when closing a project the old working directory set is changed to be again the user default/home directory) is still failing. Locally, I can see that when closing a project the path in the working directory toolbar is the correct one for an split second but then after the console finishes loading it changes to use the user default/home directory: |
This is the default behavior @dalthviz, i.e. when closing a project the first console's cwd is set to the user's home directory. What would you expect it to be? The cwd before the project was open? |
Yep exactly |
Ok, that sounds like a reasonable expectation when there's a single console open (as in the gif you posted above). However, if users have many of them, we would have to use as the "previous cwd" the one of the console which has focus before the project is open. And in that case, I don't know if users would be surprised by us setting the cwd when the project is closed to what could appear to be a random directory, specially if they forgot what was the cwd of the last console with focus. |
I see, also if the current behavior is the default behavior then I guess this is ok 👍 . Maybe creating a new issue to discuss that behavior in the ux-improvements repo could be worthy, but for sure not something to address here. So, besides the comment I left for the |
Also expand the docstring of that method.
Good idea. I opened spyder-ide/ux-improvements#74 to keep track of this discussion. |
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.
Thanks @ccordoba12 👍
Description of Changes
set_working_directory
, which I broke in PR PR: Add new API methods to the IPython console #18544.save_working_directory
to save the cwd reported by the Working directory plugin. This is necessary to start new consoles.Issue(s) Resolved
Fixes #19003
Affirmation
By submitting this Pull Request or typing my (user)name below,
I affirm the Developer Certificate of Origin
with respect to all commits and content included in this PR,
and understand I am releasing the same under Spyder's MIT (Expat) license.
I certify the above statement is true and correct: @ccordoba12