Skip to content

Commit b027f37

Browse files
fix: add empty yaml guidance
1 parent 68399cb commit b027f37

File tree

1 file changed

+34
-5
lines changed
  • src/webview/SearchSidebar/SearchProviderMessage

1 file changed

+34
-5
lines changed

src/webview/SearchSidebar/SearchProviderMessage/index.tsx

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,43 @@ const codeStyle = {
1919
fontSize: 'var(--vscode-font-size)',
2020
} as const
2121

22+
function EmptyYaml({ id }: { id: string | undefined }) {
23+
return (
24+
<div style={style}>
25+
No results found for YAML <code style={codeStyle}>{id}</code>.
26+
<br />
27+
If this is unexpected, you can try:
28+
<ul style={ulStyle}>
29+
<li>
30+
Simplify the rule and code. Start from a minimal example.
31+
</li>
32+
<li>
33+
<VSCodeLink href="https://ast-grep.github.io/advanced/faq.html#why-is-rule-matching-order-sensitive">
34+
Rule order
35+
</VSCodeLink>{' '}
36+
can be important. Try using <code>all</code>.
37+
</li>
38+
<li>
39+
<VSCodeLink href="https://ast-grep.github.io/guide/rule-config/relational-rule.html#stopby">
40+
Relational rules
41+
</VSCodeLink>{' '}
42+
like <code>has</code>/<code>inside</code>) needs <code>stopBy: end</code>.
43+
</li>
44+
<li>
45+
Adjust your gitignore files.{' '}
46+
<VSCodeLink href="https://ast-grep.github.io/reference/cli/run.html#no-ignore-file-type">
47+
See doc
48+
</VSCodeLink>
49+
</li>
50+
</ul>
51+
</div>
52+
)
53+
}
54+
2255
function Empty({ query }: { query: SearchQuery }) {
2356
if ('yaml' in query) {
2457
const id = /id:\s*([^,\n]+)/.exec(query.yaml)?.[1]
25-
return (
26-
<div style={style}>
27-
No results found for YAML <code style={codeStyle}>{id}</code>
28-
</div>
29-
)
58+
return <EmptyYaml id={id} />
3059
}
3160
const { pattern, includeFile } = query
3261
return (

0 commit comments

Comments
 (0)