@@ -102,17 +102,29 @@ define(function (require, exports, module) {
102102 * @param {string= } fontSizeStyle A string with the font size and the size unit
103103 */
104104 function _setSizeAndRestoreScroll ( fontSizeStyle ) {
105- var editor = EditorManager . getCurrentFullEditor ( ) ,
106- oldWidth = editor . _codeMirror . defaultCharWidth ( ) ,
107- scrollPos = editor . getScrollPos ( ) ,
108- line = editor . _codeMirror . lineAtHeight ( scrollPos . y , "local" ) ;
105+ var editor = EditorManager . getCurrentFullEditor ( ) ,
106+ oldWidth = editor . _codeMirror . defaultCharWidth ( ) ,
107+ oldFontSize = $ ( ".CodeMirror" ) . css ( "font-size" ) ,
108+ newFontSize = "" ,
109+ delta = 0 ,
110+ adjustment = 0 ,
111+ scrollPos = editor . getScrollPos ( ) ,
112+ line = editor . _codeMirror . lineAtHeight ( scrollPos . y , "local" ) ;
109113
110114 _removeDynamicFontSize ( ) ;
111115 if ( fontSizeStyle ) {
112116 _addDynamicFontSize ( fontSizeStyle ) ;
113117 }
114118 editor . refreshAll ( ) ;
115119
120+ delta = / e m $ / . test ( oldFontSize ) ? 10 : 1 ;
121+ newFontSize = $ ( ".CodeMirror" ) . css ( "font-size" ) ;
122+ adjustment = parseInt ( ( parseFloat ( newFontSize ) - parseFloat ( oldFontSize ) ) * delta , 10 ) ;
123+
124+ if ( adjustment ) {
125+ $ ( exports ) . triggerHandler ( "fontSizeChange" , [ adjustment , newFontSize ] ) ;
126+ }
127+
116128 // Calculate the new scroll based on the old font sizes and scroll position
117129 var newWidth = editor . _codeMirror . defaultCharWidth ( ) ,
118130 deltaX = scrollPos . x / oldWidth ,
@@ -153,7 +165,6 @@ define(function (require, exports, module) {
153165 _setSizeAndRestoreScroll ( fsStr ) ;
154166 PreferencesManager . setViewState ( "fontSizeStyle" , fsStr ) ;
155167
156- $ ( exports ) . triggerHandler ( "fontSizeChange" , [ adjustment , fsStr ] ) ;
157168 return true ;
158169 }
159170
0 commit comments