@@ -38,7 +38,7 @@ import { provideCodeActions } from './providers/codeActions/codeActionProvider'
38
38
import { registerDocumentColorProvider } from './providers/documentColorProvider'
39
39
40
40
let connection = createConnection ( ProposedFeatures . all )
41
- let state : State = { enabled : false , emitter : createEmitter ( connection ) }
41
+ const state : State = { enabled : false , emitter : createEmitter ( connection ) }
42
42
let documents = new TextDocuments ( )
43
43
let workspaceFolder : string | null
44
44
@@ -74,7 +74,7 @@ connection.onInitialize(
74
74
async ( params : InitializeParams ) : Promise < InitializeResult > => {
75
75
const capabilities = params . capabilities
76
76
77
- const editorState : EditorState = {
77
+ state . editor = {
78
78
connection,
79
79
documents,
80
80
documentSettings,
@@ -100,24 +100,15 @@ connection.onInitialize(
100
100
// @ts -ignore
101
101
onChange : ( newState : State ) : void => {
102
102
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 } )
109
104
connection . sendNotification ( 'tailwindcss/configUpdated' , [
110
105
state . configPath ,
111
106
state . config ,
112
107
state . plugins ,
113
108
] )
114
109
updateAllDiagnostics ( state )
115
110
} else {
116
- state = {
117
- enabled : false ,
118
- emitter : state . emitter ,
119
- editor : editorState ,
120
- }
111
+ state . enabled = false
121
112
if ( newState && newState . error ) {
122
113
const payload : {
123
114
message : string
@@ -141,14 +132,9 @@ connection.onInitialize(
141
132
)
142
133
143
134
if ( tailwindState ) {
144
- state = {
145
- enabled : true ,
146
- emitter : state . emitter ,
147
- editor : editorState ,
148
- ...tailwindState ,
149
- }
135
+ Object . assign ( state , tailwindState , { enabled : true } )
150
136
} else {
151
- state = { enabled : false , emitter : state . emitter , editor : editorState }
137
+ state . enabled = false
152
138
}
153
139
154
140
return {
0 commit comments