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

Paths in the "Search in" combobox of the "Find in File" plugin becomes corrupted #5306

Closed
jnsebgosselin opened this issue Sep 21, 2017 · 15 comments

Comments

@jnsebgosselin
Copy link
Member

jnsebgosselin commented Sep 21, 2017

Description of your problem

Related to PR #4822 that fixed Issues #4814 and #4809.

What steps will reproduce the problem?

  1. I don't know... I'm sorry. I'll add more info in the future if I can. I'm using this feature a lot, so I'll keep my eyes opened!

What is the expected output? What do you see instead?

Sometimes, Other directories in the Search in combobox of the Find in File plugin becomes corrupted with no way of removing them. For instance, the <PyQt5.QtWidgets.QListWidget... shown in the screenshot below was actually C:\Users\jsgosselin\spyder before it became corrupted at some point. This is the third time that this problem occurs for me.

Besides, I think an option should be added below Select other directory to clear the list.

image

Please provide any additional information below

Versions and main components

  • Spyder Version: branch 3.x and master
  • Python Version: 3.6.2
  • Qt Version: 5.9.1
  • PyQt Version: 5.9
  • Operating system: Windows 7 64 bits

Dependencies

IPython >=4.0 : 6.1.0 (OK)
cython >=0.21 : 0.25.2 (OK)
jedi >=0.9.0 : 0.10.2 (OK)
nbconvert >=4.0 : 5.2.1 (OK)
numpy >=1.7 : 1.13.0 (OK)
pandas >=0.13.1 : 0.20.3 (OK)
pycodestyle >=2.3: 2.3.1 (OK)
pyflakes >=0.6.0 : 1.5.0 (OK)
pygments >=2.0 : 2.2.0 (OK)
pylint >=0.25 : 1.7.1 (OK)
qtconsole >=4.2.0: 4.4.0.dev (OK)
rope >=0.9.4 : 0.10.7 (OK)
sphinx >=0.6.6 : 1.6.2 (OK)
sympy >=0.7.3 : None (NOK)

@jnsebgosselin jnsebgosselin changed the title Paths in_ Search in_ of the _Find in File_ plugin becomes corrupted Paths in the "Search in" combobox of the "Find in File" plugin becomes corrupted Sep 21, 2017
@jnsebgosselin
Copy link
Member Author

jnsebgosselin commented Oct 4, 2017

Here is a traceback:

Traceback (most recent call last):
  File "C:\Users\jsgosselin\spyder\spyder\widgets\findinfiles.py", line 114, in run
    self.find_files_in_path(self.rootpath)
  File "C:\Users\jsgosselin\spyder\spyder\widgets\findinfiles.py", line 132, in find_files_in_path
    for path, dirs, files in os.walk(path):
  File "C:\Python36\lib\os.py", line 335, in walk
    top = fspath(top)
TypeError: expected str, bytes or os.PathLike object, not NoneType

@ccordoba12 ccordoba12 added this to the v3.2.5 milestone Oct 4, 2017
@ccordoba12
Copy link
Member

@andfoy, please take a look at this one.

@ccordoba12 ccordoba12 modified the milestones: v3.2.5, v3.2.6 Dec 6, 2017
@jnsebgosselin
Copy link
Member Author

@andfoy Would you mind if I take a look at this? I would like to fix this bug for the next release.

@ccordoba12 ccordoba12 assigned jnsebgosselin and unassigned andfoy Dec 19, 2017
@ccordoba12
Copy link
Member

Jean, please go ahead and fix it 👍

@jnsebgosselin
Copy link
Member Author

jnsebgosselin commented Dec 20, 2017

@ccordoba12 In addition to solve this issue, I had some ideas to improve how the Search in QComboBox works. What do you think?

  • When populating the Search in QComboBox, do not add the paths that do not exists anymore.
  • When hovering over an item of the QComboBox and pressing Del, remove the item from the list.
  • Add a Clear this list option below Select other directory.
  • Show the full path when hovering over an item in the Search in QComboBox.

@jnsebgosselin
Copy link
Member Author

  File "C:\Users\jsgosselin\spyder\spyder\widgets\findinfiles.py", line 408, in path_selection_changed
    self.external_path = item.path
AttributeError: 'QListWidgetItem' object has no attribute 'path'

@ccordoba12
Copy link
Member

Jean, I agree with all your suggestions.

@jnsebgosselin
Copy link
Member Author

jnsebgosselin commented Dec 29, 2017

The traceback posted in #5306 (comment) does not seem to be related to the undesired behavior described in the OP.

Traceback (most recent call last):
  File "C:\Users\jsgosselin\spyder\spyder\widgets\findinfiles.py", line 115, in run
    self.find_files_in_path(self.rootpath)
  File "C:\Users\jsgosselin\spyder\spyder\widgets\findinfiles.py", line 133, in find_files_in_path
    for path, dirs, files in os.walk(path):
  File "C:\Python36\lib\os.py", line 335, in walk
    top = fspath(top)
TypeError: expected str, bytes or os.PathLike object, not NoneType

To reproduce this error:

  • Open a project in Spyder.
  • Go in the Find in Files plugin and from the Search in combobox, select the Project option.
  • Close the project.
  • Start the search.

fif_error1

@jnsebgosselin
Copy link
Member Author

jnsebgosselin commented Dec 29, 2017

The traceback posted in #5306 (comment). does not seem to be related to the undesired behavior described in the OP. So far unfortunately, I have not been successful to produce a reproducible example of the issue described in the OP.

Traceback (most recent call last):
  File "C:\Users\jsgosselin\spyder\spyder\widgets\findinfiles.py", line 408, in path_selection_changed
    item = self.path_selection_contents.item(idx)
AttributeError: 'QListWidgetItem' object has no attribute 'path'

To reproduce this error:

  • Select a path in the Search in combobox.
  • Change the selection by rolling up the mouse wheel until the separator below the Select other directory is hit.

fif_error2

@ccordoba12 ccordoba12 modified the milestones: v3.2.6, v3.2.7 Dec 29, 2017
@jnsebgosselin
Copy link
Member Author

Ok, I found out how to reproduce the behaviour described in the OP 😂. This is happening when Enter is pressed when the focus is on the Search in combo-box and when an external path is selected.

The currently selected path is then moved at the beginning of the list, and an empty item is also added. This behaviour is explained by the keyPressEvent override in the BaseComboBox, from which the Search in combo-box is inheriting

Because of this, the wrong information is saved in the configuration file when the FindinFiles plugin is closed afterward. In the get_options method, the external paths are retrieved from index 6 of the Search in combo-box (see here). Due to what was explained above, the content that is supposed to be in index 1 to 5 is pushed down in the list. So running to_text_string on items that are not an instance of ExternalPathItem, such as a separator, returns a string of the object such as <PyQt5.QtWidgets.QListWidget...

fif_error3

@ccordoba12
Copy link
Member

Great! So PR coming?

@jnsebgosselin
Copy link
Member Author

@ccordoba12 Do I fix the 3 issues I've found while investigating this (see #5306 (comment), #5306 (comment), and #5306 (comment)) and do I implement the 4 proposed enhancements (see #5306 (comment)) in the same PR or do I split this in smaller, individual PR?

@ccordoba12
Copy link
Member

Everything in one PR seems easier to me because all fixes/improvements are related.

@jnsebgosselin
Copy link
Member Author

@ccordoba12 Alright thank you. The PR is on the way :)

@ccordoba12
Copy link
Member

Ok, moving this one to 3.2.6 then :-)

@ccordoba12 ccordoba12 modified the milestones: v3.2.7, v3.2.6 Dec 29, 2017
@ccordoba12 ccordoba12 removed this from the v3.2.6 milestone Jan 4, 2018
@ccordoba12 ccordoba12 added this to the v3.2.7 milestone Jan 4, 2018
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

3 participants