[WIP] Search redux#3370
Conversation
|
|
||
| while ((result = query.exec(_text))) { | ||
| indices.push({ | ||
| id: source.id, |
There was a problem hiding this comment.
This enables us know the source attached to the match
jasonLaster
left a comment
There was a problem hiding this comment.
Wow - looking great!
| import * as ui from "./ui"; | ||
| import * as ast from "./ast"; | ||
| import * as coverage from "./coverage"; | ||
| import * as search from "./search"; |
There was a problem hiding this comment.
perhaps project-text-search
| .filter(source => source.has("text")) | ||
| .toJS(); | ||
|
|
||
| validSources.forEach(source => { |
There was a problem hiding this comment.
perhaps:
for (const source of validSources) {
const matches = await searchSource(source, query);
dispatch({ ya da ya da });
}This strategy will let us defer the work to the worker. each search will be a new worker call and will wait for the response to come back...
|
|
||
| componentDidMount() { | ||
| if (this.state.inputValue == "") { | ||
| this.props.loadAllSources(); |
There was a problem hiding this comment.
another option would be to move this to the searchSources action...
the advantage is that we always do it before we search. often it will be very fast... and then we know we have everything to search
| } | ||
|
|
||
| selectMatchItem(matchItem) { | ||
| this.props.selectSource(matchItem.id); |
| className: classnames("result", { focused }), | ||
| key: `${match.line}/${match.column}`, | ||
| onClick: () => console.log(`clicked ${match}`) | ||
| key: `${match.line}-${match.column}`, |
There was a problem hiding this comment.
we might need to have the source id here too
| case "ADD_QUERY": | ||
| return state.update("query", value => action.query); | ||
|
|
||
| case "REMOVE_QUERY": |
There was a problem hiding this comment.
minor thing, but clear is being used in other places clear_query
|
|
||
| case "ADD_SEARCH_RESULT": | ||
| return state.updateIn( | ||
| ["results", action.result.id], |
There was a problem hiding this comment.
perhaps action.result.sourceId
| type OuterState = { search: Record<SearchState> }; | ||
|
|
||
| export function getSearchResults(state: OuterState) { | ||
| return state.search.get("results").valueSeq().toJS(); |
There was a problem hiding this comment.
lets expose I state.search.get("results")
There was a problem hiding this comment.
@jlast Is there any particular reason behind this? Just for my understanding.
There was a problem hiding this comment.
Immutable lets us compare items and see if they change list.get("id") === list.get("id")
There was a problem hiding this comment.
Can you please tag jasonlaster instead of me?
Codecov Report
@@ Coverage Diff @@
## master #3370 +/- ##
==========================================
- Coverage 50.76% 50.43% -0.34%
==========================================
Files 105 107 +2
Lines 4353 4386 +33
Branches 896 900 +4
==========================================
+ Hits 2210 2212 +2
- Misses 2143 2174 +31
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## next #3370 +/- ##
==========================================
+ Coverage 50.03% 50.52% +0.49%
==========================================
Files 107 107
Lines 4457 4388 -69
Branches 920 900 -20
==========================================
- Hits 2230 2217 -13
+ Misses 2227 2171 -56
Continue to review full report at Codecov.
|
jasonLaster
left a comment
There was a problem hiding this comment.
couple small comments, then it's ready to go in!
|
|
||
| export function searchSources(query) { | ||
| return async ({ dispatch, getState }: ThunkArgs) => { | ||
| dispatch(await loadAllSources()); |
There was a problem hiding this comment.
perhaps we want to do something to disallow new searches while one is going on?
I do this with preview, by having an updating state: https://github.com/devtools-html/debugger.html/blob/master/src/reducers/ast.js#L21-L22
|
|
||
| while ((result = query.exec(_text))) { | ||
| indices.push({ | ||
| id: source.id, |
| import type { PauseState } from "./pause"; | ||
| import type { SourcesState } from "./source"; | ||
| import type { BreakpointsState } from "./breakpoints"; | ||
| import type { SearchState } from "./search"; |
There was a problem hiding this comment.
hmm - does this need to be updated?
| ast, | ||
| coverage | ||
| coverage, | ||
| search |
There was a problem hiding this comment.
should be projectTextSearch
| ui, | ||
| ast, | ||
| coverage, | ||
| search, |
There was a problem hiding this comment.
should be projectTextSearch
|
Happy to land this and iterate. I'll leave some UX feedback on the parent issue |
| type: "CLEAR_SELECTION" | ||
| }; | ||
|
|
||
| export type ProjectTextSearchAction = { |
There was a problem hiding this comment.
it was a nightmare resolving flow issues
|
To add tests |
| deleteIn(keyPath: Array<any>, ...iterables: Array<any>): Record<T>, | ||
| update<A>(key: $Keys<T>, value: A): Record<T>, | ||
| updateIn(keyPath: Array<any>, ...iterables: Array<any>): Record<T>, | ||
| remove<A>(key: $Keys<T>): Record<T>, |
|
Great work @bomsy! |
Associated Issue: #3342
Summary of Changes
Todo