-
-
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: More find in files improvements #4599
Conversation
Great! Thanks a lot for working on this. I'll look at it in couple of hours. |
@andfoy, unfortunately this is not working for minified Javascript files: Perhaps we could also take 10 chars to left and right, and if their length is smaller than taking 4 words to left and right, then use that instead. What do you think? |
@ccordoba12 It sounds great! I'll implement it and test if it works |
Let's make it 20 chars to left and right. 10 seems too little.
El 15/06/17 a las 15:42, Edgar Andrés Margffoy Tuay escribió:
…
@ccordoba12 <https://github.com/ccordoba12> It sounds great! I'll
implement it and test if it works
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4599 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAWS7f-CzL4keuBfGg358ndj_Vs1S9bfks5sEZctgaJpZM4N4Ak5>.
|
@andfoy, this is looking great! I fixed a minor bug I found, and still have some more comments:
|
@ccordoba12 Should I disable sorting feature? |
No, the idea would be that after a search has finished, users would be able to sort files, but not while it's running. |
I will implement that then! |
You left a print statement around, that's why tests are failing. |
spyder/widgets/findinfiles.py
Outdated
@@ -786,6 +797,8 @@ def closing_widget(self): | |||
|
|||
def search_complete(self, completed): | |||
"""Current search thread has finished""" | |||
self.result_browser.enable_sorting(True) | |||
self.result_browser.enable_sorting(True) |
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.
This line is repeated.
spyder/widgets/findinfiles.py
Outdated
@@ -576,6 +612,10 @@ def activated(self, item): | |||
filename, lineno, colno = itemdata | |||
self.parent().edit_goto.emit(filename, lineno, self.search_text) | |||
|
|||
def enable_sorting(self, flag): | |||
"""Enable result sorting after search is complete.""" | |||
self.sorting_status['status'] = flag |
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.
Why this has to be a dictionary instead of a property? I mean, you could simply have
self.sorting = True/False
instead of having a method called enable_sorting
that writes to a dict.
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.
But if I modify a property, will it propagate along all elements?
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.
Ok, then let's refactor this a bit so it's easier to understand. What about
self.sorting['status'] = 'on'/'off'
?
spyder/widgets/findinfiles.py
Outdated
@@ -596,7 +637,8 @@ def append_result(self, results, num_matches): | |||
filename, lineno, colno, line = results | |||
|
|||
if filename not in self.files: | |||
item = FileMatchItem(self, filename) | |||
item = FileMatchItem(self, filename, self.sorting_status) |
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.
I disable sorting only on file entries and not line entries, to accomplish that I use the dict
I tested your latest changes and there are some more bugs:
|
Forget about point 2. I had the same files in two different directories because I was creating wheels for Spyder before to fix another bug ;-) |
It seems that disabling sorting features while a search is taking place helps to unblock the result browser. However, most of the overhead is caused by adding multiple results simultaneously |
Ok, what if we show new results after a file has been scanned completely, instead of showing each new result at a time? |
So, should we fallback to our previous search behaviour and compare it with the actual? |
What previous one exactly? The one in 3.1 or before you did this PR? |
The one present on #4056 |
I think performance dropped by using whole file matches. Should I try to disable automatic expansion of results? |
I don't understand what you mean
I think rendering results is not the problem. I disabled all rendering to try to find where performance is being affected, and the Editor was still very unresponsive. So I don't think that's the cause, so it should be in SearchThread instead. |
Maybe line cropping should be done on the results viewer instead of being done on the Thread? |
Probably, I was also thinking that. |
I'll give it a try |
It seems that truncating lines outside the Thread improves search performance |
@ccordoba12 Does the last commit addresses the two issues? |
Absolutely!! There's still a bit of lag but the situation improved considerably! Please do the required cleanup (you left a lot of comments in your last commit), then I'll merge. I'm really happy with the results! Thanks a lot for putting so much love in our Find in Files. |
spyder/widgets/findinfiles.py
Outdated
def find_string_in_file(self, fname): | ||
self.error_flag = False | ||
self.sig_current_file.emit(fname) | ||
# results = {} | ||
# results = [] |
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.
Please also remove this comment.
Fixes #4596