diff --git a/spec/text-editor-spec.coffee b/spec/text-editor-spec.coffee index 432502238..4d4a80d24 100644 --- a/spec/text-editor-spec.coffee +++ b/spec/text-editor-spec.coffee @@ -155,6 +155,25 @@ describe "TextEditor", -> expect(editor2.getSoftTabs()).toBe true expect(editor2.getEncoding()).toBe 'macroman' + it "uses scoped `core.fileEncoding` values" + editor1 = null + editor2 = null + + atom.config.set('core.fileEncoding', 'utf16le') + atom.config.set('core.fileEncoding', 'macroman', { scopeSelector: '.javascript' }) + + waitsForPromise -> + atom.workspace.open('a').then (o) -> editor1 = o + + runs -> + expect(editor1.getEncoding()).toBe 'utf16le' + + waitsForPromise -> + atom.workspace.open('test.js').then (o) -> editor2 = o + + runs -> + expect(editor2.getEncoding()).toBe 'macroman' + describe "title", -> describe ".getTitle()", -> it "uses the basename of the buffer's path as its title, or 'untitled' if the path is undefined", -> diff --git a/src/text-editor.coffee b/src/text-editor.coffee index f3b3bc5c2..8519be042 100644 --- a/src/text-editor.coffee +++ b/src/text-editor.coffee @@ -105,7 +105,7 @@ class TextEditor extends Model @languageMode = new LanguageMode(this) - @setEncoding(atom.config.get(@getRootScopeDescriptor(), "core.fileEncoding")) + @setEncoding(atom.config.get("core.fileEncoding", { scope: @getRootScopeDescriptor() })) @subscribe @$scrollTop, (scrollTop) => @emit 'scroll-top-changed', scrollTop