Repository navigation
index test_that() calls for fuzzy finder - #11102
Conversation
|
Nice! I think this (or a version of this) will be very useful. Some comments:
For the first point, one thing we could consider is allowing for a special "prefix" for matching test files. For example, you could type: to find all tests with a description matching "mutate". (This is modeled after Qt Creator's omni-search; we should consider discussing if we want to adopt this approach, and whether it might make sense to extend this to other unique prefixes, e.g. Let's ask Hadley + others if they have any strong feelings. |
|
Interesting. it would be nice if we can come up with a syntax to restrict what is searched for.
cc @hadley We already have the This goes to line 10 of |
|
I think including the test calls in the fuzzy file finder is much less compelling that including them in the document navigator, because I think most people don't really remember the names of tests. Having them in the navigator is useful because it helps you see the shape of tests in the one file; I suspect having them in the fff is likely to lead to false positives when you're trying to match other things. I think it would be feasible if, as @kevinushey suggests, there was some way to select only tests, but I think that would necessitate a larger redesign of the fff, as you'd also need to expose the user to the filtering options in some way. |
|
I've open another pr for the initial request: #11108 For this, I'd often want to jump to a test, but I vaguely remember where it is. I'd definitely use something like this, instead of what I'm doing currently: use find in files. It's alright, but it's just less smooth. But I agree that what I'm looking for here is some way to search within the tests only. Would rarely/never need them to be presented alongside other kinds of results. |
This comment was marked as off-topic.
This comment was marked as off-topic.
fe93e69 to
45fe3d8
Compare
Would it be straightforward to disable that? Overall LGTM; I think we should file separate issues regarding:
|
Yeah for sure, we could easily only display tests when the term starts with "t ". It's probably not a very relevant search term anyway. Let me just do that. |
864d302 to
fe7cf9f
Compare
|
Now The code might need some refactoring if we then decide to do other prefix later. |
b9fad66 to
b0b9fc1
Compare
| if (clone.isType(RToken::STRING)) | ||
| { | ||
| static const boost::regex removeQuotesRegex("^['\"](.*)['\"]$"); | ||
| static const boost::regex removeRawStringQuotesRegex("^r['\"][(](.*)[)]['\"]$"); |
There was a problem hiding this comment.
Raw strings in R are very permissive; for example:
> R"(abc)"
[1] "abc"
> R"{abc}"
[1] "abc"
> R"[abc]"
[1] "abc"
> R"--[abc]--"
[1] "abc"
That is, you can use r or R to begin a raw string, a variable number of - separators, and also your own choice of (, { or [. See for example:
rstudio/src/cpp/core/r_util/RTokenizer.cpp
Lines 248 to 353 in 50af541
Rather than a regular expression, because we know the token must already be a string, I think you should do something like the following:
- Check for a leading
rorRfor a raw string versus a "regular" string, - Find the index of the first character of
"({[", - Use that to extract the inner substring of the raw string, e.g.
content.substr(<start>, <end>)where both<start>and<end>are computed based on the size of the raw string prefix.
In practice I doubt any user is going to use raw strings in this context, and even if they do the worst case is they see the raw string as-is in the UI, so that's probably not the end of the world.
There was a problem hiding this comment.
Thanks. I'll forget about this until someone someday uses a raw string in a test_that() description.
* show test_that() calls in document outline * use test icon * style test items in the outline * +NEWS * Make function assignments secundary in test files * nodeLabelSecundary not italic * hyperlink get no default color (#11147) * update rstheme * update expected rstheme * 🇫🇷 for "plot" is "graphique" (#11148) * update plot french text * more * tracé -> graphique * plural * `uiLanguage*` properties in fr (#11119) * uiLanguage* properties in french * add trainling : in fr and en * visual editor: auto-prefix footnotes in included files support for 'editor' metadata options in files and projects * index `test_that()` calls for fuzzy finder (#11102) * index test_that calls for fuzzy finder * use moveToNextSignificantToken() * Don't unclude test_that() in the string * rm quote from test desc * make removeQuoteRegex static const * testThatCAllIndexer adds "t " prefix * only show test items if the search term starts with "t " * fuzzy finder removes artifical "t " prefix * remove dead code * When search term starts with "t ", only include test items * not looking for files and C++ items when only looking for test items * NEWS * factor out includeTestItems * handle raw string in test_that(<raw string>) * Update src/gwt/acesupport/acemode/r_scope_tree.js Co-authored-by: Kevin Ushey <[email protected]> * show test_that() calls in document outline * use test icon * style test items in the outline * +NEWS * Make function assignments secundary in test files * nodeLabelSecundary not italic * use opacity 0.8 * opacity: .7 * .nodeLabelSecundary:hover Co-authored-by: JJ Allaire <[email protected]> Co-authored-by: Kevin Ushey <[email protected]>







Intent
part of #11082
Approach
Index the calls to
test_that()so that they are presented by the fuzzy finder:Automated Tests
QA Notes
Checklist
NEWS.md