@@ -38,7 +38,7 @@ import { provideCodeActions } from './providers/codeActions/codeActionProvider'
3838import { registerDocumentColorProvider } from './providers/documentColorProvider'
3939
4040let connection = createConnection ( ProposedFeatures . all )
41- let state : State = { enabled : false , emitter : createEmitter ( connection ) }
41+ const state : State = { enabled : false , emitter : createEmitter ( connection ) }
4242let documents = new TextDocuments ( )
4343let workspaceFolder : string | null
4444
@@ -74,7 +74,7 @@ connection.onInitialize(
7474 async ( params : InitializeParams ) : Promise < InitializeResult > => {
7575 const capabilities = params . capabilities
7676
77- const editorState : EditorState = {
77+ state . editor = {
7878 connection,
7979 documents,
8080 documentSettings,
@@ -100,24 +100,15 @@ connection.onInitialize(
100100 // @ts -ignore
101101 onChange : ( newState : State ) : void => {
102102 if ( newState && ! newState . error ) {
103- state = {
104- ...newState ,
105- enabled : true ,
106- emitter : state . emitter ,
107- editor : editorState ,
108- }
103+ Object . assign ( state , newState , { enabled : true } )
109104 connection . sendNotification ( 'tailwindcss/configUpdated' , [
110105 state . configPath ,
111106 state . config ,
112107 state . plugins ,
113108 ] )
114109 updateAllDiagnostics ( state )
115110 } else {
116- state = {
117- enabled : false ,
118- emitter : state . emitter ,
119- editor : editorState ,
120- }
111+ state . enabled = false
121112 if ( newState && newState . error ) {
122113 const payload : {
123114 message : string
@@ -141,14 +132,9 @@ connection.onInitialize(
141132 )
142133
143134 if ( tailwindState ) {
144- state = {
145- enabled : true ,
146- emitter : state . emitter ,
147- editor : editorState ,
148- ...tailwindState ,
149- }
135+ Object . assign ( state , tailwindState , { enabled : true } )
150136 } else {
151- state = { enabled : false , emitter : state . emitter , editor : editorState }
137+ state . enabled = false
152138 }
153139
154140 return {
0 commit comments