udapte var names

pull/5370/head
filip mertens 3 years ago
parent d6462bb5c9
commit 7fa5b22d9c
  1. 8
      libs/remix-ui/search/src/lib/components/Exclude.tsx
  2. 2
      libs/remix-ui/search/src/lib/components/Find.tsx
  3. 6
      libs/remix-ui/search/src/lib/components/Include.tsx
  4. 14
      libs/remix-ui/search/src/lib/context/context.tsx

@ -3,16 +3,16 @@ import { SearchContext } from '../context/context'
export const Exclude = props => { export const Exclude = props => {
const { setExclude, state } = useContext(SearchContext) const { setExclude, state } = useContext(SearchContext)
const [str, setStr] = useState<string>('.git/**/*,.deps/**/*') const [excludeInput, setExcludeInput] = useState<string>('.git/**/*,.deps/**/*')
const timeOutId = useRef(null) const timeOutId = useRef(null)
const change = e => { const change = e => {
setStr(e.target.value) setExcludeInput(e.target.value)
clearTimeout(timeOutId.current) clearTimeout(timeOutId.current)
timeOutId.current = setTimeout(() => setExclude(e.target.value), 500) timeOutId.current = setTimeout(() => setExclude(e.target.value), 500)
} }
useEffect(() => { useEffect(() => {
setExclude(str) setExclude(excludeInput)
}, []) }, [])
return ( return (
@ -24,7 +24,7 @@ export const Exclude = props => {
placeholder="Exclude ie .git/**/*" placeholder="Exclude ie .git/**/*"
className="form-control" className="form-control"
onChange={change} onChange={change}
value={str} value={excludeInput}
></input> ></input>
</div> </div>
</> </>

@ -1,7 +1,7 @@
import React, { useContext, useRef } from 'react' import React, { useContext, useRef } from 'react'
import { SearchContext } from '../context/context' import { SearchContext } from '../context/context'
export const Find = props => { export const Find = () => {
const { const {
setFind, setFind,
state, state,

@ -3,10 +3,10 @@ import { SearchContext } from '../context/context'
export const Include = props => { export const Include = props => {
const { setInclude } = useContext(SearchContext) const { setInclude } = useContext(SearchContext)
const [str, setStr] = useState<string>('') const [includeInput, setIncludeInput] = useState<string>('')
const timeOutId = useRef(null) const timeOutId = useRef(null)
const change = e => { const change = e => {
setStr(e.target.value) setIncludeInput(e.target.value)
clearTimeout(timeOutId.current) clearTimeout(timeOutId.current)
timeOutId.current = setTimeout(() => setInclude(e.target.value), 500) timeOutId.current = setTimeout(() => setInclude(e.target.value), 500)
} }
@ -20,7 +20,7 @@ export const Include = props => {
placeholder="Include ie contracts/**/*.sol" placeholder="Include ie contracts/**/*.sol"
className="form-control" className="form-control"
onChange={change} onChange={change}
value={str} value={includeInput}
></input> ></input>
</div> </div>
</> </>

@ -205,17 +205,17 @@ export const SearchProvider = ({
useEffect(() => { useEffect(() => {
if (state.find) { if (state.find) {
(async () => { (async () => {
const res = await getDirectory('/', plugin) const files = await getDirectory('/', plugin)
const pathFilter: any = {} const pathFilter: any = {}
if (state.include){ if (state.include){
const inc = state.include.replaceAll(/(?<!\/)(\*\.)/g, '**/*.') const includeWithGlobalExpression = state.include.replaceAll(/(?<!\/)(\*\.)/g, '**/*.')
pathFilter.include = inc.split(',').map(i => i.trim()) pathFilter.include = includeWithGlobalExpression.split(',').map(i => i.trim())
} }
if (state.exclude){ if (state.exclude){
const exc = state.exclude.replaceAll(/(?<!\/)(\*\.)/g, '**/*.') const excludeWithGlobalExpression = state.exclude.replaceAll(/(?<!\/)(\*\.)/g, '**/*.')
pathFilter.exclude = state.exclude.split(',').map(i => i.trim()) pathFilter.exclude = excludeWithGlobalExpression.split(',').map(i => i.trim())
} }
const ob = res.filter(filePathFilter(pathFilter)).map(file => { const filteredFiles = files.filter(filePathFilter(pathFilter)).map(file => {
const r: SearchResult = { const r: SearchResult = {
filename: file, filename: file,
lines: [], lines: [],
@ -226,7 +226,7 @@ export const SearchProvider = ({
} }
return r return r
}) })
value.setSearchResults(ob) value.setSearchResults(filteredFiles)
})() })()
} }
}, [state.timeStamp]) }, [state.timeStamp])

Loading…
Cancel
Save