@@ -69,6 +69,7 @@ define(function (require, exports, module) {
69
69
var AnimationUtils = require ( "utils/AnimationUtils" ) ,
70
70
Async = require ( "utils/Async" ) ,
71
71
CodeMirror = require ( "thirdparty/CodeMirror2/lib/codemirror" ) ,
72
+ LanguageManager = require ( "language/LanguageManager" ) ,
72
73
EventDispatcher = require ( "utils/EventDispatcher" ) ,
73
74
Menus = require ( "command/Menus" ) ,
74
75
PerfUtils = require ( "utils/PerfUtils" ) ,
@@ -178,6 +179,19 @@ define(function (require, exports, module) {
178
179
return true ;
179
180
}
180
181
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
+
181
195
/**
182
196
* List of all current (non-destroy()ed) Editor instances. Needed when changing global preferences
183
197
* that affect all editors, e.g. tabbing or color scheme settings.
@@ -656,7 +670,7 @@ define(function (require, exports, module) {
656
670
/**
657
671
* Determine the mode to use from the document's language
658
672
* 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
660
674
*/
661
675
Editor . prototype . _getModeFromDocument = function ( ) {
662
676
// 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) {
2159
2173
* @return {* } current value of that pref
2160
2174
*/
2161
2175
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 ( ) ) ) ;
2163
2177
} ;
2164
2178
2165
2179
/**
@@ -2247,7 +2261,7 @@ define(function (require, exports, module) {
2247
2261
2248
2262
2249
2263
// Global settings that affect Editor instances that share the same preference locations
2250
-
2264
+
2251
2265
/**
2252
2266
* Sets whether to use tab characters (vs. spaces) when inserting new text.
2253
2267
* Affects any editors that share the same preference location.
@@ -2266,7 +2280,7 @@ define(function (require, exports, module) {
2266
2280
* @return {boolean }
2267
2281
*/
2268
2282
Editor . getUseTabChar = function ( fullPath ) {
2269
- return PreferencesManager . get ( USE_TAB_CHAR , fullPath ) ;
2283
+ return PreferencesManager . get ( USE_TAB_CHAR , _buildPreferencesContext ( fullPath ) ) ;
2270
2284
} ;
2271
2285
2272
2286
/**
@@ -2287,7 +2301,7 @@ define(function (require, exports, module) {
2287
2301
* @return {number }
2288
2302
*/
2289
2303
Editor . getTabSize = function ( fullPath ) {
2290
- return PreferencesManager . get ( TAB_SIZE , fullPath ) ;
2304
+ return PreferencesManager . get ( TAB_SIZE , _buildPreferencesContext ( fullPath ) ) ;
2291
2305
} ;
2292
2306
2293
2307
/**
@@ -2308,7 +2322,7 @@ define(function (require, exports, module) {
2308
2322
* @return {number }
2309
2323
*/
2310
2324
Editor . getSpaceUnits = function ( fullPath ) {
2311
- return PreferencesManager . get ( SPACE_UNITS , fullPath ) ;
2325
+ return PreferencesManager . get ( SPACE_UNITS , _buildPreferencesContext ( fullPath ) ) ;
2312
2326
} ;
2313
2327
2314
2328
/**
@@ -2329,7 +2343,7 @@ define(function (require, exports, module) {
2329
2343
* @return {boolean }
2330
2344
*/
2331
2345
Editor . getCloseBrackets = function ( fullPath ) {
2332
- return PreferencesManager . get ( CLOSE_BRACKETS , fullPath ) ;
2346
+ return PreferencesManager . get ( CLOSE_BRACKETS , _buildPreferencesContext ( fullPath ) ) ;
2333
2347
} ;
2334
2348
2335
2349
/**
@@ -2350,7 +2364,7 @@ define(function (require, exports, module) {
2350
2364
* @return {boolean }
2351
2365
*/
2352
2366
Editor . getShowLineNumbers = function ( fullPath ) {
2353
- return PreferencesManager . get ( SHOW_LINE_NUMBERS , fullPath ) ;
2367
+ return PreferencesManager . get ( SHOW_LINE_NUMBERS , _buildPreferencesContext ( fullPath ) ) ;
2354
2368
} ;
2355
2369
2356
2370
/**
@@ -2370,7 +2384,7 @@ define(function (require, exports, module) {
2370
2384
* @return {boolean }
2371
2385
*/
2372
2386
Editor . getShowActiveLine = function ( fullPath ) {
2373
- return PreferencesManager . get ( STYLE_ACTIVE_LINE , fullPath ) ;
2387
+ return PreferencesManager . get ( STYLE_ACTIVE_LINE , _buildPreferencesContext ( fullPath ) ) ;
2374
2388
} ;
2375
2389
2376
2390
/**
@@ -2391,7 +2405,7 @@ define(function (require, exports, module) {
2391
2405
* @return {boolean }
2392
2406
*/
2393
2407
Editor . getWordWrap = function ( fullPath ) {
2394
- return PreferencesManager . get ( WORD_WRAP , fullPath ) ;
2408
+ return PreferencesManager . get ( WORD_WRAP , _buildPreferencesContext ( fullPath ) ) ;
2395
2409
} ;
2396
2410
2397
2411
/**
0 commit comments