@@ -26,7 +26,7 @@ var EditorsHandler = function () {
2626 this . defaultFileExt = null ;
2727 this . undefinedFileMode = null ;
2828 this . undefinedFileIcon = null ;
29-
29+ this . undefinedFileName = null ;
3030
3131 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
3232 /// Private Helper
@@ -60,6 +60,8 @@ var EditorsHandler = function () {
6060 that . undefinedFileMode = data . undefinedFile . mode ;
6161 // noinspection JSUnresolvedVariable
6262 that . undefinedFileIcon = data . undefinedFile . icon ;
63+ // noinspection JSUnresolvedVariable
64+ that . undefinedFileName = data . undefinedFile . name ;
6365
6466 deferred . resolve ( ) ;
6567 } ) ;
@@ -256,27 +258,25 @@ var EditorsHandler = function () {
256258 return false ;
257259 }
258260
259- var that = this ;
261+ var that = this ;
262+ var aceEditor = this . getEditor ( idx ) ;
263+
264+ if ( typeof aceEditor === typeof undefined ) {
265+ return false ;
266+ }
260267
261268 idx = parseInt ( idx ) ;
262- if ( typeof fileEntry !== typeof undefined ) {
263- chrome . fileSystem . getDisplayPath ( fileEntry , function ( path ) {
264- var aceEditor = that . getEditor ( idx ) ;
265- if ( typeof aceEditor !== typeof undefined ) {
269+ this . _getTabMode ( idx ) . then ( function ( data ) {
270+ if ( JSON . parse ( data ) . mode === that . undefinedFileMode ) {
271+ chrome . fileSystem . getDisplayPath ( fileEntry , function ( path ) {
266272 that . getEditor ( idx ) . setOption ( 'mode' , that . Modelist . getModeForPath ( path ) . mode ) ;
267273 that . _populateStatusBar ( idx ) ;
268- }
269- } ) ;
270- }
271- else {
272- this . _getTabMode ( idx ) . then ( function ( data ) {
273- var aceEditor = that . getEditor ( idx ) ;
274- if ( typeof aceEditor !== typeof undefined ) {
275- that . getEditor ( idx ) . setOption ( 'mode' , 'ace/mode/' + JSON . parse ( data ) . mode ) ;
276- that . _populateStatusBar ( idx ) ;
277- }
278- } ) ;
279- }
274+ } ) ;
275+ } else {
276+ that . getEditor ( idx ) . setOption ( 'mode' , 'ace/mode/' + JSON . parse ( data ) . mode ) ;
277+ that . _populateStatusBar ( idx ) ;
278+ }
279+ } ) ;
280280 } ;
281281
282282 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -391,7 +391,7 @@ var EditorsHandler = function () {
391391 deferred . resolve ( JSON . stringify ( {
392392 "icon" : that . undefinedFileIcon ,
393393 "mode" : that . undefinedFileMode ,
394- "name" : "Text"
394+ "name" : that . undefinedFileName
395395 } ) ) ;
396396 }
397397 if ( data . hasOwnProperty ( ext ) ) {
@@ -664,7 +664,7 @@ var EditorsHandler = function () {
664664 }
665665 } ) ;
666666 } ) ;
667-
667+
668668 ace . require ( "ace/ext/chromevox" ) ;
669669 } ;
670670
0 commit comments