|
|
@ -202,18 +202,28 @@ export const SearchProvider = ({ |
|
|
|
} |
|
|
|
} |
|
|
|
}, []) |
|
|
|
}, []) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//*.sol, **/*.txt, contracts/*
|
|
|
|
|
|
|
|
const setGlobalExpression = (paths: string) => { |
|
|
|
|
|
|
|
const results = [] |
|
|
|
|
|
|
|
paths.split(',').forEach(path => { |
|
|
|
|
|
|
|
path = path.trim() |
|
|
|
|
|
|
|
if(path.startsWith('*.')) path = path.replace(/(\*\.)/g, '**/*.') |
|
|
|
|
|
|
|
if(path.endsWith('/*') && !path.endsWith('/**/*')) path = path.replace(/(\*)/g, '**/*.*') |
|
|
|
|
|
|
|
results.push(path) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
return results |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
if (state.find) { |
|
|
|
if (state.find) { |
|
|
|
(async () => { |
|
|
|
(async () => { |
|
|
|
const files = await getDirectory('/', plugin) |
|
|
|
const files = await getDirectory('/', plugin) |
|
|
|
const pathFilter: any = {} |
|
|
|
const pathFilter: any = {} |
|
|
|
if (state.include){ |
|
|
|
if (state.include){ |
|
|
|
const includeWithGlobalExpression = state.include.replaceAll(/(\*\.)/g, '**/*.') |
|
|
|
pathFilter.include = setGlobalExpression(state.include) |
|
|
|
pathFilter.include = includeWithGlobalExpression.split(',').map(i => i.trim()) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (state.exclude){ |
|
|
|
if (state.exclude){ |
|
|
|
const excludeWithGlobalExpression = state.exclude.replaceAll(/(\*\.)/g, '**/*.') |
|
|
|
pathFilter.exclude = setGlobalExpression(state.exclude) |
|
|
|
pathFilter.exclude = excludeWithGlobalExpression.split(',').map(i => i.trim()) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
const filteredFiles = files.filter(filePathFilter(pathFilter)).map(file => { |
|
|
|
const filteredFiles = files.filter(filePathFilter(pathFilter)).map(file => { |
|
|
|
const r: SearchResult = { |
|
|
|
const r: SearchResult = { |
|
|
|