Skip to content

Commit f8a73da

Browse files
committed
refactor: force enable globs
1 parent 6e0d6e2 commit f8a73da

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/extension/search.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,13 @@ export function buildCommand(query: SearchQuery) {
127127
if (query.lang) {
128128
args.push('--lang', query.lang)
129129
}
130-
args.push(...includeFile.split(',').filter(Boolean))
130+
const validIncludeFile = includeFile.split(',').filter(Boolean)
131+
const hasGlobPattern = validIncludeFile.some(i => i.includes('*'))
132+
if (hasGlobPattern) {
133+
args.push(...validIncludeFile.map(i => `--globs=${i}`))
134+
} else {
135+
args.push(...validIncludeFile)
136+
}
131137
console.debug('running', query, command, args)
132138
// TODO: multi-workspaces support
133139
return spawn(command, args, {

src/webview/SearchSidebar/SearchProviderMessage/index.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ function Empty({ query }: { query: SearchQuery }) {
7171
.
7272
</li>
7373
) : null}
74+
{query.includeFile.length ? (
75+
<li>
76+
If you're using glob patterns in the include file, please ensure
77+
that your version of ast-grep is above{' '}
78+
<code style={codeStyle}>v0.28.0</code>.
79+
</li>
80+
) : null}
7481
<li>
7582
Adjust your gitignore files.{' '}
7683
<VSCodeLink href="https://ast-grep.github.io/reference/cli/run.html#no-ignore-file-type">

src/webview/SearchSidebar/SearchWidgetContainer/IncludeFile.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default function IncludeFile({
2525
<h4 style={titleStyle}>files to include</h4>
2626
<SearchInput
2727
isSingleLine={true}
28-
placeholder="e.g. src, packages. No glob pattern"
28+
placeholder="e.g. src, packages, src/**/*.ts"
2929
value={includeFile}
3030
onChange={setIncludeFile}
3131
onKeyEnterUp={refreshResult}

0 commit comments

Comments
 (0)