File tree Expand file tree Collapse file tree 4 files changed +60
-2
lines changed Expand file tree Collapse file tree 4 files changed +60
-2
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,8 @@ function clearSearchResults() {
125125}
126126
127127function enableYAML ( ) {
128+ parentPort . postMessage ( 'enableYAML' , true )
129+ parentPort . postMessage ( 'clearSearchResults' , { } )
128130 vscode . commands . executeCommand (
129131 'setContext' ,
130132 'ast-grep.yamlMode' ,
@@ -133,6 +135,8 @@ function enableYAML() {
133135}
134136
135137function enablePattern ( ) {
138+ parentPort . postMessage ( 'enableYAML' , false )
139+ parentPort . postMessage ( 'clearSearchResults' , { } )
136140 vscode . commands . executeCommand (
137141 'setContext' ,
138142 'ast-grep.yamlMode' ,
Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ export interface ParentToChild {
7070 clearSearchResults : unknown
7171 toggleAllSearch : unknown
7272 searchByCode : { text : string }
73+ enableYAML : boolean
7374}
7475
7576export interface Diff {
Original file line number Diff line number Diff line change 1+ import * as stylex from '@stylexjs/stylex'
2+ import { VSCodeButton , VSCodeTextArea } from '@vscode/webview-ui-toolkit/react'
3+ import { useState } from 'react'
4+
5+ const styles = stylex . create ( {
6+ yaml : {
7+ marginLeft : 18 ,
8+ display : 'flex' ,
9+ flexDirection : 'column' ,
10+ } ,
11+ editor : {
12+ width : '100%' ,
13+ } ,
14+ searchButton : {
15+ marginTop : 4 ,
16+ alignSelf : 'flex-end' ,
17+ } ,
18+ } )
19+
20+ export default function YamlWidget ( ) {
21+ const [ value , setValue ] = useState ( '' )
22+ return (
23+ < div { ...stylex . props ( styles . yaml ) } >
24+ < VSCodeTextArea
25+ { ...stylex . props ( styles . editor ) }
26+ value = { value }
27+ placeholder = "YAML configuration"
28+ resize = "vertical"
29+ onInput = { ( e : any ) => {
30+ const newValue = e . target . value || ''
31+ setValue ( newValue )
32+ } }
33+ />
34+ < VSCodeButton
35+ { ...stylex . props ( styles . searchButton ) }
36+ appearance = "primary"
37+ onClick = { ( ) => {
38+ // Handle save or apply logic here
39+ console . log ( 'YAML Config:' , value )
40+ } }
41+ >
42+ Search
43+ </ VSCodeButton >
44+ </ div >
45+ )
46+ }
Original file line number Diff line number Diff line change 1- import { memo } from 'react'
1+ import { memo , useState } from 'react'
2+ import { useEffectOnce } from 'react-use'
3+ import { childPort } from '../../postMessage'
24import SearchOptions from './SearchOptions'
35import SearchWidget from './SearchWidget'
6+ import YamlWidget from './YamlWidget'
47
58function SearchWidgetContainer ( ) {
9+ const [ isYaml , setIsYaml ] = useState ( false )
10+ useEffectOnce ( ( ) => {
11+ childPort . onMessage ( 'enableYAML' , setIsYaml )
12+ } )
613 return (
714 < div style = { { margin : '0 12px 0 2px' } } >
8- < SearchWidget />
15+ { isYaml ? < YamlWidget /> : < SearchWidget /> }
916 < SearchOptions />
1017 </ div >
1118 )
You can’t perform that action at this time.
0 commit comments