@@ -80,6 +80,7 @@ define(function (require, exports, module) {
80
80
TokenUtils = require ( "utils/TokenUtils" ) ,
81
81
ValidationUtils = require ( "utils/ValidationUtils" ) ,
82
82
ViewUtils = require ( "utils/ViewUtils" ) ,
83
+ MainViewManager = require ( "view/MainViewManager" ) ,
83
84
_ = require ( "thirdparty/lodash" ) ;
84
85
85
86
/** Editor preferences */
@@ -310,9 +311,12 @@ define(function (require, exports, module) {
310
311
this . _handleDocumentChange = this . _handleDocumentChange . bind ( this ) ;
311
312
this . _handleDocumentDeleted = this . _handleDocumentDeleted . bind ( this ) ;
312
313
this . _handleDocumentLanguageChanged = this . _handleDocumentLanguageChanged . bind ( this ) ;
314
+ this . _doWorkingSetSync = this . _doWorkingSetSync . bind ( this ) ;
313
315
document . on ( "change" , this . _handleDocumentChange ) ;
314
316
document . on ( "deleted" , this . _handleDocumentDeleted ) ;
315
317
document . on ( "languageChanged" , this . _handleDocumentLanguageChanged ) ;
318
+ // To sync working sets if the view is for same doc across panes
319
+ document . on ( "_dirtyFlagChange" , this . _doWorkingSetSync ) ;
316
320
317
321
var mode = this . _getModeFromDocument ( ) ;
318
322
@@ -325,6 +329,9 @@ define(function (require, exports, module) {
325
329
326
330
this . _$messagePopover = null ;
327
331
332
+ // To track which pane the editor is being attached to if it's a full editor
333
+ this . _paneId = null ;
334
+
328
335
// Editor supplies some standard keyboard behavior extensions of its own
329
336
var codeMirrorKeyMap = {
330
337
"Tab" : function ( ) { self . _handleTabKey ( ) ; } ,
@@ -449,6 +456,20 @@ define(function (require, exports, module) {
449
456
EventDispatcher . makeEventDispatcher ( Editor . prototype ) ;
450
457
EventDispatcher . markDeprecated ( Editor . prototype , "keyEvent" , "'keydown/press/up'" ) ;
451
458
459
+ Editor . prototype . markPaneId = function ( paneId ) {
460
+ this . _paneId = paneId ;
461
+ // In case this Editor is initialized not as the first full editor for the document
462
+ // and the document is already dirty and present in another working set, make sure
463
+ // to add this documents to the new panes working set.
464
+ this . _doWorkingSetSync ( null , this . document ) ;
465
+ } ;
466
+
467
+ Editor . prototype . _doWorkingSetSync = function ( event , doc ) {
468
+ if ( doc === this . document && this . _paneId && this . document . isDirty ) {
469
+ MainViewManager . addToWorkingSet ( this . _paneId , this . document . file , - 1 , false ) ;
470
+ }
471
+ } ;
472
+
452
473
/**
453
474
* Removes this editor from the DOM and detaches from the Document. If this is the "master"
454
475
* Editor that is secretly providing the Document's backing state, then the Document reverts to
@@ -468,6 +489,7 @@ define(function (require, exports, module) {
468
489
this . document . off ( "change" , this . _handleDocumentChange ) ;
469
490
this . document . off ( "deleted" , this . _handleDocumentDeleted ) ;
470
491
this . document . off ( "languageChanged" , this . _handleDocumentLanguageChanged ) ;
492
+ this . document . off ( "_dirtyFlagChange" , this . _doWorkingSetSync ) ;
471
493
472
494
if ( this . _visibleRange ) { // TextRange also refs the Document
473
495
this . _visibleRange . dispose ( ) ;
@@ -476,6 +498,8 @@ define(function (require, exports, module) {
476
498
// If we're the Document's master editor, disconnecting from it has special meaning
477
499
if ( this . document . _masterEditor === this ) {
478
500
this . document . _makeNonEditable ( ) ;
501
+ } else {
502
+ this . document . _disassociateEditor ( this ) ;
479
503
}
480
504
481
505
// Destroying us destroys any inline widgets we're hosting. Make sure their closeCallbacks
@@ -961,6 +985,8 @@ define(function (require, exports, module) {
961
985
this . _codeMirror . on ( "focus" , function ( ) {
962
986
self . _focused = true ;
963
987
self . trigger ( "focus" , self ) ;
988
+ // Set this full editor as master editor for the document
989
+ self . document . _toggleMasterEditor ( self ) ;
964
990
} ) ;
965
991
966
992
this . _codeMirror . on ( "blur" , function ( ) {
0 commit comments