Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit b71b8c9

Browse files
committed
Make PrefixedPreferencesSystem context aware.
1 parent dde2613 commit b71b8c9

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

src/document/DocumentManager.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -695,18 +695,21 @@ define(function (require, exports, module) {
695695
oldDoc.off("languageChanged.DocumentManager");
696696
}
697697

698-
if (newDoc !== oldDoc) {
699-
// Dispatch deprecated event with doc args (not File args as the new event uses)
700-
exports.trigger("currentDocumentChange", newDoc, oldDoc);
701-
}
702-
703698
if (newDoc) {
699+
PreferencesManager._setCurrentLanguage(newDoc.getLanguage().getId());
704700
newDoc.on("languageChanged.DocumentManager", function (e, oldLang, newLang) {
705701
PreferencesManager._setCurrentLanguage(newLang.getId());
706702
exports.trigger("currentDocumentLanguageChanged", [oldLang, newLang]);
707703
});
704+
} else {
705+
PreferencesManager._setCurrentLanguage(undefined);
708706
}
709707

708+
if (newDoc !== oldDoc) {
709+
// Dispatch deprecated event with doc args (not File args as the new event uses)
710+
exports.trigger("currentDocumentChange", newDoc, oldDoc);
711+
}
712+
710713
});
711714

712715
// Deprecated APIs

src/preferences/PreferencesBase.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,8 @@ define(function (require, exports, module) {
10621062
* @param {Object=} context Optional context object to change the preference lookup
10631063
*/
10641064
get: function (id, context) {
1065-
return this.base.get(this.prefix + id, context);
1065+
context = context || {};
1066+
return this.base.get(this.prefix + id, this.base._getContext(context));
10661067
},
10671068

10681069
/**

src/preferences/PreferencesManager.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,13 @@ define(function (require, exports, module) {
422422
var ctx = {};
423423
if (filename) {
424424
ctx.path = filename;
425+
} else {
426+
ctx.path = currentFilename;
425427
}
426428
if (languageId) {
427429
ctx.language = languageId;
430+
} else {
431+
ctx.language = currentLanguageId;
428432
}
429433
ctx.scopeOrder = _includeProjectScope(ctx.path) ?
430434
scopeOrderWithProject :

0 commit comments

Comments
 (0)