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

Return value of EditorStack.has_filename not checked properly #5776

Closed
csabella opened this issue Nov 16, 2017 · 0 comments
Closed

Return value of EditorStack.has_filename not checked properly #5776

csabella opened this issue Nov 16, 2017 · 0 comments
Assignees
Milestone

Comments

@csabella
Copy link
Contributor

While writing tests for the editor stack save functions for issue #5703, I noticed a separate issue in the way that the return value from has_filename was being used. has_filename returns a list index for the location of the file in self.data, which can include 0 as a valid value. If the file is not found, then the function returns None.

In some of the code that calls has_filename (including code from the save functions), the code was written as if not has_filename(fname). I believe the intention was to skip the code when the file wasn't found, but an unintentional side effect is that it was skipping the code when the index was 0.

During save_as and save_copy_as, this skipped code was used to close a file if the new, selected save as name was the same as an existing, open file.

Here's another way to see a side-effect of skipping index 0:

  1. Open 2 or 3 files from the Recent files list. When a file is opened, it is removed from recent files.
  2. Notice, however, that the file on tab 0 remains on the recent file list.
  3. Swap tab 0 and tab 1 in the editor.
  4. Look at recent files again. Notice now that the filename for the file that had been in position 1 is now on recent files and that the file moved to position 1 has been removed from recent files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants