Skip to content
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: Editor historystack improvements #5229

Merged
merged 3 commits into from
Sep 15, 2017

Conversation

rlaverde
Copy link
Member

@rlaverde rlaverde commented Sep 13, 2017

Fixes: #5226

I think the error was the unnecessary side effect of _get_previous_file_index, although I wasn't able to reproduce #5226

…vent that posible corruptions raise an error.)
_get_previous_file_index shouldn't modify stack_history,
the stack history will be modified when the file close and
current_changed is raised

Modifing stack_history in _get_previous_file_index cause
corruptions in the history when the close of the file is cancelled.
@rlaverde rlaverde added this to the v3.2.4 milestone Sep 13, 2017
@rlaverde rlaverde self-assigned this Sep 13, 2017
@rlaverde rlaverde requested a review from ccordoba12 September 13, 2017 18:08
try:
return self.id_list.index(self.history[i])
except ValueError:
self.refresh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be self.refresh(), right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thanks for noticing it

return self.id_list.index(self.history[i])
except ValueError:
self.refresh
raise IndexError
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to raise an IndexError here?

Copy link
Member Author

@rlaverde rlaverde Sep 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's the expected bevahior, when an element isn't found in a list an IndexError is raised.

The other option will be to return None, when an error occurs

if len(self.stack_history) > 1:
last = len(self.stack_history)-1
w_id = self.stack_history.pop(last)
self.stack_history.insert(0, w_id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove this?

Copy link
Member Author

@rlaverde rlaverde Sep 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was an unnecessary side effect, that could cause the corruption of the historystack order.

This code reordered the stackhiistory before closing the file, the closing could be canceled, an the stackhistory will have a wrong order.

Also this was unnecessary, because when a file is closed the CurrentChanged signal is be emited, and that cause the history_stack to be updated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks for the explanation :-)

@ccordoba12 ccordoba12 changed the base branch from master to 3.x September 15, 2017 06:21
@ccordoba12 ccordoba12 merged commit 9224248 into spyder-ide:3.x Sep 15, 2017
ccordoba12 added a commit that referenced this pull request Sep 15, 2017
@rlaverde rlaverde deleted the editor-historystack-improvements branch September 15, 2017 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants