-
Notifications
You must be signed in to change notification settings - Fork 300
Add a 'find in files' quick-menu #2315
Add a 'find in files' quick-menu #2315
Conversation
c9950a5
to
8618e94
Compare
Codecov Report
@@ Coverage Diff @@
## master #2315 +/- ##
==========================================
- Coverage 42.67% 42.62% -0.05%
==========================================
Files 325 332 +7
Lines 13131 13212 +81
Branches 1728 1736 +8
==========================================
+ Hits 5603 5632 +29
- Misses 7249 7302 +53
+ Partials 279 278 -1
Continue to review full report at Codecov.
|
Gave it a test and works fine for me! One thing that struck me was if the search is in a menu bar, does it not make sense for the results to be in there as well? Though that could potentially warrant an issue to get some comments. I know there was talks of a combo search box. Ie Ctrl-p but if you prefix the search with ? its file wise, > is commands, nothing is fuzzy finder etcetc. |
I haven't had the time to try it myself but I agree with @CrossR re. the results I think one of my main blockers for using the search feature is that the results get placed in another window I have to navigate to would be nice to have an FZF like Rg command that the results were what the menu is poplulated with and you can just select the one you want |
How about this:
The results will appear in the drop down box of the menu (like c-p).
Enter will set the results to quick-fix.
C-{Enter/v/h} will act like in c-p menu.
…On Sun, Jun 17, 2018, 16:03 Akin ***@***.***> wrote:
I haven't had the time to try it myself but I agree with @CrossR
<https://github.com/CrossR> re. the results I think one of my main
blockers for using the search feature is that the results get placed in
another window I have to navigate to would be nice to have an FZF like Rg
command that the results were what the menu is poplulated with and you can
just select the one you want
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#2315 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AE3IjR0A2nd75pXlhwi2fcZYpOZBC2Xjks5t9lOUgaJpZM4UnB0D>
.
|
@TalAmuyal that sounds good think its a good idea to have a way of saving the results anyway, re. Enter as saving to the qf menu (my own 2 cents here) I think the definitive action should be opening the result and the optional action should be opening in the qf e.g. |
a650afc
to
f21b05d
Compare
Note: I pulled out the whole QuickOpen folder as a stand-alone plugin and merged the find-in-file functionality as another use-case. The code is refactored since it was a bit tangled and was hard for me to just inject the additional logic. |
} | ||
|
||
public async searchFileByContent() { | ||
const filterName = "none" |
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.
Should this be a config option?
My first instinct was to try and use smart search (ie case insenstive unless you use uppercase characters), which then failed.
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 "none"
is intentional.
This filter
field is a second filtering done after rg
.
Since rg
can accept a regex, a search string like ab.*cd
will be computed as rg ab.*cd | egrep "ab\.\*cd"
which will very likely cause similar searches the yield no results.
However:
- Found the reason that smart-case didn't work and fixed it.
- Added a TODO to use a filter for highlighting w/ support for regex.
I tried the regexFilter
for the menu, but it throws some exceptions.
It might be that a slight update/variation can fix it. (But I prefer to do less changes that will keep this PR further for merging)
(Will push soon)
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.
P.S: fixed the latency/hanging issue.
Couple of general thoughts: When selecting something using the For larger Repos, the Similarly, swapping between big repos seems to cause issues where the previous repos files are still shown. I think the process for ripgrep may not be being closed or something, since I saw the menu fighting between repos and swapping back and forth between results from two different repos. I'm not too sure what the fix here is, but I did get a "
So perhaps that is the line taking up most of the time? At the point of the crash I had just short of 4GB used, so something must be up. Also I had duplicated items somehow: When I was testing on smaller repos, worked as expected and looks good tho! Some of the memory stuff may just be us not controlling ripgrep correctly or its results, since it should be fine. |
@CrossR, thanks for the fast review! Regarding the performance issue, it should be better now and I have an idea for another improvement, though I prefer to have it in a future PR since it requires another API change. Regarding opening in the right place - fixed! :P Also added tests :) |
98ffb89
to
9ad6ec1
Compare
I can give the tests a run on my Windows machine if that would help? I think I can see part of the issue, so I'll stick a review comment on. |
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.
test/ci/QuickOpenTest.ts
Outdated
await oni.automation.sleep(100) | ||
anyOni.automation.sendKeysV2("<CR>") | ||
const editor = oni.editors.activeEditor | ||
await oni.automation.waitFor(() => editor.activeBuffer.filePath.endsWith("/SearchProvider.ts")) |
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.
Windows paths use \
rather than /
so this is most likely failing on Windows.
Ie, the output for me in this file on my machine is "F:\User Files\Documents\Git\oni\browser\src\Services\Search\SearchProvider.ts"
, so this will never pass on Windows.
I think you either need to remove the /
, or if a path separator is needed, convert the filepath.
test/ci/QuickOpenTest.ts
Outdated
oni.commands.executeCommand("quickOpen.searchFileByContent") | ||
await oni.automation.waitFor(() => oni.menu.isMenuOpen()) | ||
await oni.automation.sleep(100) | ||
anyOni.automation.sendKeysV2("^exp.*?class.*?Qu.*?Op.*?Item") |
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'm not fully sure what this search string is doing, but it kills my dev instance, so I assume that it either does the same to the tests, or its taking that long the correct file isn't opened (a few times on my machine I saw ACCOUNTING.md
opened instead).
Perhaps its worth changing this, or swapping the working directory to a different folder in the Oni repo, so the search is easier?
test/ci/QuickOpenTest.ts
Outdated
anyOni.automation.sendKeysV2("^exp.*?class.*?Qu.*?Op.*?Item") | ||
await oni.automation.sleep(100) | ||
anyOni.automation.sendKeysV2("<CR>") | ||
await oni.automation.sleep(500) |
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.
On my machine, I needed slightly longer sleeps, so I swapped them all to 2000
.
test/ci/QuickOpenTest.ts
Outdated
anyOni.automation.sendKeysV2("<CR>") | ||
await oni.automation.sleep(500) | ||
const filePath = oni.editors.activeEditor.activeBuffer.filePath | ||
assert.assert(filePath.endsWith("QuickOpenItem.ts"), `filePath`) |
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 was hitting issues with this assert where the test was finding itself! So it would search for some string and the first occurrence would be the test file itself. I think if you swap the search string to something unique to the test (MyUniqueTestString
) and then assert the file is the test file, you should get better results.
@CrossR, thanks a bunch for that last batch or comments - I am now confident that I can make it work on the CI servers! |
9ad6ec1
to
9fd162a
Compare
Sweet! Thanks for all the help @CrossR ! 💯 |
13b85e3
to
864fe09
Compare
d45a522
to
54bf22e
Compare
a98ac62
to
51a526e
Compare
@CrossR, when you have the time, please provide feedback or approve this PR. |
b818854
to
91f18ae
Compare
91f18ae
to
8d69256
Compare
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.
Issues I had last time seem to be fixed now!
One bug I have noticed is that is looks like hidden folders are ignored, so searching for something in there seems to fail. Ie, try searching for a number from the config.yml
in the .github
folder in the Oni repo.
That said....its a small bug, so I think its worth getting this merged so it can be used. The bug can be fixed later, and it lets us get more feedback. May be worth waiting for @bryphe or @akin909 input on that too though?
It sounds like a fairly small bug that can be fixed in a follow up PR I'd love to see this functionality personally 👍 |
Sounds good to me! |
I'm so happy it is finally merged that I'm almost tearful... |
Thanks for all the hard work on it, @TalAmuyal ! Excited it made it in too! 🎉 |
Disclaimer:
I (shamelessly) copied the code from the sidebar's search and injected it into a copy of
QuickOpen
.Personally, I find it more useful that way.
The "new" feature is called
QuickFind
:P