@@ -69,6 +69,7 @@ define(function (require, exports, module) {
6969 var AnimationUtils = require ( "utils/AnimationUtils" ) ,
7070 Async = require ( "utils/Async" ) ,
7171 CodeMirror = require ( "thirdparty/CodeMirror2/lib/codemirror" ) ,
72+ LanguageManager = require ( "language/LanguageManager" ) ,
7273 EventDispatcher = require ( "utils/EventDispatcher" ) ,
7374 Menus = require ( "command/Menus" ) ,
7475 PerfUtils = require ( "utils/PerfUtils" ) ,
@@ -178,6 +179,19 @@ define(function (require, exports, module) {
178179 return true ;
179180 }
180181
182+ /**
183+ * Helper function to build preferences context based on the full path of
184+ * the file.
185+ *
186+ * @param {string } fullPath Full path of the file
187+ *
188+ * @return {* } A context for the specified file name
189+ */
190+ function _buildPreferencesContext ( fullPath ) {
191+ return PreferencesManager . _buildContext ( fullPath ,
192+ fullPath ? LanguageManager . getLanguageForPath ( fullPath ) . getId ( ) : undefined ) ;
193+ }
194+
181195 /**
182196 * List of all current (non-destroy()ed) Editor instances. Needed when changing global preferences
183197 * that affect all editors, e.g. tabbing or color scheme settings.
@@ -656,7 +670,7 @@ define(function (require, exports, module) {
656670 /**
657671 * Determine the mode to use from the document's language
658672 * Uses "text/plain" if the language does not define a mode
659- * @return string The mode to use
673+ * @return { string } The mode to use
660674 */
661675 Editor . prototype . _getModeFromDocument = function ( ) {
662676 // We'd like undefined/null/"" to mean plain text mode. CodeMirror defaults to plaintext for any
@@ -2159,7 +2173,7 @@ define(function (require, exports, module) {
21592173 * @return {* } current value of that pref
21602174 */
21612175 Editor . prototype . _getOption = function ( prefName ) {
2162- return PreferencesManager . get ( prefName , this . document . file . fullPath ) ;
2176+ return PreferencesManager . get ( prefName , PreferencesManager . _buildContext ( this . document . file . fullPath , this . document . getLanguage ( ) . getId ( ) ) ) ;
21632177 } ;
21642178
21652179 /**
@@ -2247,7 +2261,7 @@ define(function (require, exports, module) {
22472261
22482262
22492263 // Global settings that affect Editor instances that share the same preference locations
2250-
2264+
22512265 /**
22522266 * Sets whether to use tab characters (vs. spaces) when inserting new text.
22532267 * Affects any editors that share the same preference location.
@@ -2266,7 +2280,7 @@ define(function (require, exports, module) {
22662280 * @return {boolean }
22672281 */
22682282 Editor . getUseTabChar = function ( fullPath ) {
2269- return PreferencesManager . get ( USE_TAB_CHAR , fullPath ) ;
2283+ return PreferencesManager . get ( USE_TAB_CHAR , _buildPreferencesContext ( fullPath ) ) ;
22702284 } ;
22712285
22722286 /**
@@ -2287,7 +2301,7 @@ define(function (require, exports, module) {
22872301 * @return {number }
22882302 */
22892303 Editor . getTabSize = function ( fullPath ) {
2290- return PreferencesManager . get ( TAB_SIZE , fullPath ) ;
2304+ return PreferencesManager . get ( TAB_SIZE , _buildPreferencesContext ( fullPath ) ) ;
22912305 } ;
22922306
22932307 /**
@@ -2308,7 +2322,7 @@ define(function (require, exports, module) {
23082322 * @return {number }
23092323 */
23102324 Editor . getSpaceUnits = function ( fullPath ) {
2311- return PreferencesManager . get ( SPACE_UNITS , fullPath ) ;
2325+ return PreferencesManager . get ( SPACE_UNITS , _buildPreferencesContext ( fullPath ) ) ;
23122326 } ;
23132327
23142328 /**
@@ -2329,7 +2343,7 @@ define(function (require, exports, module) {
23292343 * @return {boolean }
23302344 */
23312345 Editor . getCloseBrackets = function ( fullPath ) {
2332- return PreferencesManager . get ( CLOSE_BRACKETS , fullPath ) ;
2346+ return PreferencesManager . get ( CLOSE_BRACKETS , _buildPreferencesContext ( fullPath ) ) ;
23332347 } ;
23342348
23352349 /**
@@ -2350,7 +2364,7 @@ define(function (require, exports, module) {
23502364 * @return {boolean }
23512365 */
23522366 Editor . getShowLineNumbers = function ( fullPath ) {
2353- return PreferencesManager . get ( SHOW_LINE_NUMBERS , fullPath ) ;
2367+ return PreferencesManager . get ( SHOW_LINE_NUMBERS , _buildPreferencesContext ( fullPath ) ) ;
23542368 } ;
23552369
23562370 /**
@@ -2370,7 +2384,7 @@ define(function (require, exports, module) {
23702384 * @return {boolean }
23712385 */
23722386 Editor . getShowActiveLine = function ( fullPath ) {
2373- return PreferencesManager . get ( STYLE_ACTIVE_LINE , fullPath ) ;
2387+ return PreferencesManager . get ( STYLE_ACTIVE_LINE , _buildPreferencesContext ( fullPath ) ) ;
23742388 } ;
23752389
23762390 /**
@@ -2391,7 +2405,7 @@ define(function (require, exports, module) {
23912405 * @return {boolean }
23922406 */
23932407 Editor . getWordWrap = function ( fullPath ) {
2394- return PreferencesManager . get ( WORD_WRAP , fullPath ) ;
2408+ return PreferencesManager . get ( WORD_WRAP , _buildPreferencesContext ( fullPath ) ) ;
23952409 } ;
23962410
23972411 /**
0 commit comments