@@ -16,7 +16,10 @@ declare let acquireVsCodeApi: any
16
16
const editor = acquireVsCodeApi ( )
17
17
const editorSend = ( action :T . Action ) => {
18
18
logger ( `TO EXT: "${ action . type } "` )
19
- return editor . postMessage ( action )
19
+ return editor . postMessage ( {
20
+ ...action ,
21
+ source :'coderoad' , // filter events by source on editor side
22
+ } )
20
23
}
21
24
22
25
// router finds first state match of <Route path='' />
@@ -31,14 +34,15 @@ const useStateMachine = (): Output => {
31
34
// event bus listener
32
35
React . useEffect ( ( ) => {
33
36
const listener = 'message'
34
- //propograte channel event to state machine
37
+ //propagate channel event to state machine
35
38
const handler = ( event :any ) => {
36
- // ensure events are coming from coderoad webview
37
- if ( ! event . origin . match ( / ^ v s c o d e - w e b v i e w / ) ) {
38
- return
39
- }
40
39
// NOTE: must call event.data, cannot destructure. VSCode acts odd
41
40
const action = event . data
41
+
42
+ if ( action . source !== 'coderoad' ) {
43
+ // filter out events from other extensions
44
+ return
45
+ }
42
46
sendWithLog ( action )
43
47
}
44
48
window . addEventListener ( listener , handler )