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: More find in files improvements #4599

Merged
merged 15 commits into from
Jun 22, 2017
Merged

Conversation

andfoy
Copy link
Member

@andfoy andfoy commented Jun 13, 2017

Fixes #4596

  • File line matches are automatically expanded
  • Lines are cropped only if they have more than 80 characters

@andfoy andfoy added this to the v3.2 milestone Jun 13, 2017
@andfoy andfoy self-assigned this Jun 13, 2017
@ccordoba12
Copy link
Member

Great! Thanks a lot for working on this. I'll look at it in couple of hours.

@ccordoba12
Copy link
Member

@andfoy, unfortunately this is not working for minified Javascript files:

seleccion_001

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?

@andfoy
Copy link
Member Author

andfoy commented Jun 15, 2017

@ccordoba12 It sounds great! I'll implement it and test if it works

@ccordoba12
Copy link
Member

ccordoba12 commented Jun 15, 2017 via email

@ccordoba12
Copy link
Member

@andfoy, this is looking great! I fixed a minor bug I found, and still have some more comments:

  1. Please truncate results with 30 chars to left and right, instead of 20. 20 is still too little.

  2. Is it possible to append new files and their results at the end of the tree widget? The thing is it's quite distracting to be reading results of one file and then see those results disappear from view because the results of a new file are shown instead. The other solution would be to not sort files by name. In any case, we need to find a solution for this.

  3. There are some terms that are not highlighted on the result line. For example, I looked for the term append in the Spyder source code, and, as you can see below, it's not highlighted in some cases. Please take a look at that too.

    seleccion_001

@ccordoba12 ccordoba12 changed the base branch from master to 3.x June 18, 2017 17:05
@andfoy
Copy link
Member Author

andfoy commented Jun 21, 2017

@ccordoba12 Should I disable sorting feature?

@ccordoba12
Copy link
Member

No, the idea would be that after a search has finished, users would be able to sort files, but not while it's running.

@andfoy
Copy link
Member Author

andfoy commented Jun 21, 2017

I will implement that then!

@ccordoba12
Copy link
Member

ccordoba12 commented Jun 21, 2017

You left a print statement around, that's why tests are failing.

@@ -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)
Copy link
Member

Choose a reason for hiding this comment

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

This line is repeated.

@@ -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
Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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'

?

@@ -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)
Copy link
Member Author

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

@ccordoba12
Copy link
Member

I tested your latest changes and there are some more bugs:

  1. Results are sorted automatically after a search finishes. That needs to be avoided, i.e. sorting needs to be applied only if the user asks for it.

  2. Results appear twice sometimes

    seleccion_001

  3. The interface is quite unresponsive while a search is taking place, e.g. scrolling in the Editor is very slow. Can we do something about it?

@ccordoba12
Copy link
Member

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 ;-)

@andfoy
Copy link
Member Author

andfoy commented Jun 21, 2017

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

@ccordoba12
Copy link
Member

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?

@andfoy
Copy link
Member Author

andfoy commented Jun 21, 2017

So, should we fallback to our previous search behaviour and compare it with the actual?

@ccordoba12
Copy link
Member

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?

@andfoy
Copy link
Member Author

andfoy commented Jun 21, 2017

The one present on #4056

@andfoy
Copy link
Member Author

andfoy commented Jun 22, 2017

I think performance dropped by using whole file matches. Should I try to disable automatic expansion of results?

@ccordoba12
Copy link
Member

I think performance dropped by using whole file matches

I don't understand what you mean

Should I try to disable automatic expansion of results?

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.

@andfoy
Copy link
Member Author

andfoy commented Jun 22, 2017

Maybe line cropping should be done on the results viewer instead of being done on the Thread?

@ccordoba12
Copy link
Member

Probably, I was also thinking that.

@andfoy
Copy link
Member Author

andfoy commented Jun 22, 2017

I'll give it a try

@andfoy
Copy link
Member Author

andfoy commented Jun 22, 2017

It seems that truncating lines outside the Thread improves search performance

@andfoy
Copy link
Member Author

andfoy commented Jun 22, 2017

@ccordoba12 Does the last commit addresses the two issues?

@ccordoba12
Copy link
Member

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.

def find_string_in_file(self, fname):
self.error_flag = False
self.sig_current_file.emit(fname)
# results = {}
# results = []
Copy link
Member

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.

@ccordoba12 ccordoba12 merged commit d7a6e45 into spyder-ide:3.x Jun 22, 2017
ccordoba12 added a commit that referenced this pull request Jun 22, 2017
@andfoy andfoy deleted the more_findinfiles branch June 14, 2019 19:10
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