@@ -59,6 +59,7 @@ export class ConnectionManager {
5959 ) => void = ( ) => null
6060 private _dispatcher = _ => { }
6161 private _first_load = true
62+ private _compositionRange : LspRange
6263
6364 constructor ( worker : Worker ) {
6465 this . _worker = worker
@@ -147,8 +148,10 @@ export class ConnectionManager {
147148 } )
148149 }
149150
150- _compositionSyncStyle ( startLine : number , endLine : number ) {
151- const classNamePrefix = 'composition-sync--on'
151+ _compositionSyncStyle ( startLine : number , endLine : number , synced : boolean ) {
152+ const classNamePrefix = synced
153+ ? 'composition-sync--on'
154+ : 'composition-sync--off'
152155
153156 // Customize the full width of Monaco editor margin using API `marginClassName`
154157 // https://github.com/microsoft/monaco-editor/blob/35eb0ef/website/typedoc/monaco.d.ts#L1533
@@ -173,14 +176,15 @@ export class ConnectionManager {
173176 return [ startLineStyle , middleLinesStyle , endLineStyle ]
174177 }
175178
176- _setEditorBlockStyle ( range : LspRange | null ) {
179+ _setEditorBlockStyle ( range : LspRange | null , synced : boolean = false ) {
180+ this . _compositionRange = range
177181 const shouldRemoveAllStyles = range == null
178182
179183 this . _compositionStyle = this . _editor . deltaDecorations (
180184 this . _compositionStyle ,
181185 shouldRemoveAllStyles
182186 ? [ ]
183- : this . _compositionSyncStyle ( range . start . line , range . end . line )
187+ : this . _compositionSyncStyle ( range . start . line , range . end . line , synced )
184188 )
185189 }
186190
@@ -348,9 +352,17 @@ export class ConnectionManager {
348352 }
349353
350354 if ( ! schema . composition . synced ) {
355+ this . _session . composition . synced = false
356+ this . _setEditorBlockStyle ( this . _compositionRange )
351357 return
352358 }
359+ const syncTurnedBackOn =
360+ schema . composition . synced && ! previousState . composition . synced
361+ if ( syncTurnedBackOn ) {
362+ this . _setEditorBlockStyle ( this . _compositionRange , true )
363+ }
353364
365+ // don't update the `this._session` until here. Since used to diffChange.
354366 this . _session = { ...schema , composition : { ...schema . composition } }
355367 const { toAdd, toRemove, shouldRemoveDefaultMsg} = this . _diffSchemaChange (
356368 schema ,
@@ -414,7 +426,7 @@ export class ConnectionManager {
414426 actions . forEach ( ( action : ActionItem ) => {
415427 switch ( action . title ) {
416428 case ActionItemCommand . CompositionRange :
417- this . _setEditorBlockStyle ( action . range )
429+ this . _setEditorBlockStyle ( action . range , true )
418430 break
419431 case ActionItemCommand . CompositionState :
420432 if ( action . state ) {
0 commit comments