diff --git a/spec/text-editor-spec.coffee b/spec/text-editor-spec.coffee index 432502238..5f7c5fabf 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: '.js') + + 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/project.coffee b/src/project.coffee index 2c5ca0291..8cee16fa2 100644 --- a/src/project.coffee +++ b/src/project.coffee @@ -280,7 +280,6 @@ class Project extends Model # Still needed when deserializing a tokenized buffer buildBufferSync: (absoluteFilePath) -> buffer = new TextBuffer({filePath: absoluteFilePath}) - buffer.setEncoding(atom.config.get('core.fileEncoding')) @addBuffer(buffer) buffer.loadSync() buffer @@ -298,7 +297,6 @@ class Project extends Model throw error buffer = new TextBuffer({filePath: absoluteFilePath}) - buffer.setEncoding(atom.config.get('core.fileEncoding')) @addBuffer(buffer) buffer.load() .then((buffer) -> buffer) diff --git a/src/text-editor.coffee b/src/text-editor.coffee index 708baa099..88b43f005 100644 --- a/src/text-editor.coffee +++ b/src/text-editor.coffee @@ -105,6 +105,8 @@ class TextEditor extends Model @languageMode = new LanguageMode(this) + @setEncoding(atom.config.get("core.fileEncoding", scope: @getRootScopeDescriptor() )) + @subscribe @$scrollTop, (scrollTop) => @emit 'scroll-top-changed', scrollTop @emitter.emit 'did-change-scroll-top', scrollTop