@@ -28,7 +28,10 @@ function activate(context) {
2828 innerHTML : state . innerHTML ,
2929 bgColor : context . globalState . get ( 'polacode.bgColor' , '#2e3440' )
3030 } )
31- setupSelectionSync ( )
31+ const selectionListener = setupSelectionSync ( )
32+ panel . onDidDispose ( ( ) => {
33+ selectionListener . dispose ( )
34+ } )
3235 setupMessageListeners ( )
3336 }
3437 } )
@@ -41,6 +44,11 @@ function activate(context) {
4144
4245 panel . webview . html = getHtmlContent ( htmlPath )
4346
47+ const selectionListener = setupSelectionSync ( )
48+ panel . onDidDispose ( ( ) => {
49+ selectionListener . dispose ( )
50+ } )
51+
4452 setupMessageListeners ( )
4553
4654 const fontFamily = vscode . workspace . getConfiguration ( 'editor' ) . fontFamily
@@ -60,8 +68,6 @@ function activate(context) {
6068 }
6169 } )
6270
63- setupSelectionSync ( )
64-
6571 function setupMessageListeners ( ) {
6672 panel . webview . onDidReceiveMessage ( ( { type, data } ) => {
6773 switch ( type ) {
@@ -102,7 +108,7 @@ function activate(context) {
102108
103109 function syncSettings ( ) {
104110 const settings = vscode . workspace . getConfiguration ( 'polacode' )
105- const editorSettings = vscode . workspace . getConfiguration ( 'editor' )
111+ const editorSettings = vscode . workspace . getConfiguration ( 'editor' , null )
106112 panel . webview . postMessage ( {
107113 type : 'updateSettings' ,
108114 shadow : settings . get ( 'shadow' ) ,
@@ -114,7 +120,7 @@ function activate(context) {
114120 }
115121
116122 function setupSelectionSync ( ) {
117- vscode . window . onDidChangeTextEditorSelection ( e => {
123+ return vscode . window . onDidChangeTextEditorSelection ( e => {
118124 if ( e . selections [ 0 ] && ! e . selections [ 0 ] . isEmpty ) {
119125 vscode . commands . executeCommand ( 'editor.action.clipboardCopyAction' )
120126 panel . postMessage ( {
0 commit comments