From 4c9e71770aea43b120e0e3101718c9bf8ea77a28 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 27 Oct 2014 17:39:45 -0700 Subject: [PATCH 01/12] Add initial TextEditor::setEncoding --- src/text-editor.coffee | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/text-editor.coffee b/src/text-editor.coffee index c8500bb4c..c98570cdc 100644 --- a/src/text-editor.coffee +++ b/src/text-editor.coffee @@ -2815,6 +2815,12 @@ class TextEditor extends Model pixelRectForScreenRange: (screenRange) -> @displayBuffer.pixelRectForScreenRange(screenRange) + setEncoding: (encoding) -> + {file} = @buffer + file.setEncoding(encoding) + file.read(true).then => + file.emitter.emit('did-change') + # Deprecated: Call {::joinLines} instead. joinLine: -> deprecate("Use TextEditor::joinLines() instead") From 25eea7d19bdd571c73dcf157deb01e1c7694e975 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 28 Oct 2014 11:10:27 -0700 Subject: [PATCH 02/12] Remove TextEditor::setEncoding --- src/text-editor.coffee | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/text-editor.coffee b/src/text-editor.coffee index c98570cdc..c8500bb4c 100644 --- a/src/text-editor.coffee +++ b/src/text-editor.coffee @@ -2815,12 +2815,6 @@ class TextEditor extends Model pixelRectForScreenRange: (screenRange) -> @displayBuffer.pixelRectForScreenRange(screenRange) - setEncoding: (encoding) -> - {file} = @buffer - file.setEncoding(encoding) - file.read(true).then => - file.emitter.emit('did-change') - # Deprecated: Call {::joinLines} instead. joinLine: -> deprecate("Use TextEditor::joinLines() instead") From 490ec1aac79d299c51e25316af7d3f574faf3926 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 28 Oct 2014 11:10:50 -0700 Subject: [PATCH 03/12] :arrow_up: pathwatcher@2.3.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index af4dd1446..fdb07a2b3 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "nslog": "^1.0.1", "oniguruma": "^3.0.4", "optimist": "0.4.0", - "pathwatcher": "^2.1.3", + "pathwatcher": "^2.3.1", "property-accessors": "^1", "q": "^1.0.1", "random-words": "0.0.1", From 35925ed349d033af688e52793b89939b3955c1ab Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 28 Oct 2014 11:31:17 -0700 Subject: [PATCH 04/12] Add encoding getter and setter --- src/text-editor.coffee | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/text-editor.coffee b/src/text-editor.coffee index c8500bb4c..e680fad8e 100644 --- a/src/text-editor.coffee +++ b/src/text-editor.coffee @@ -568,6 +568,16 @@ class TextEditor extends Model # Essential: Returns the {String} path of this editor's text buffer. getPath: -> @buffer.getPath() + # Extended: Returns the {String} character set encoding of this editor's text + # buffer. + getEncoding: -> @buffer.getEncoding() + + # Extended: Set the character set encoding to use in this editor's text + # buffer. + # + # * `encoding` The {String} character set encoding name such as 'utf8' + setEncoding: (encoding) -> @buffer.setEncoding(encoding) + # Essential: Returns {Boolean} `true` if this editor has been modified. isModified: -> @buffer.isModified() From d2ef888f222e991be25910c356e8d83062054ea0 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 28 Oct 2014 11:31:27 -0700 Subject: [PATCH 05/12] Add TextEditor::onDidChangeEncoding --- src/text-editor.coffee | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/text-editor.coffee b/src/text-editor.coffee index e680fad8e..b0143ea71 100644 --- a/src/text-editor.coffee +++ b/src/text-editor.coffee @@ -134,6 +134,8 @@ class TextEditor extends Model @emitter.emit 'did-change-title', @getTitle() @emit "path-changed" @emitter.emit 'did-change-path', @getPath() + @subscribe @buffer.onDidChangeEncoding => + @emitter.emit 'did-change-encoding', @getEncoding() @subscribe @buffer.onDidDestroy => @destroy() # TODO: remove these thwne we remove the deprecations. They are old events. @@ -260,6 +262,14 @@ class TextEditor extends Model onDidChangeSoftWrapped: (callback) -> @displayBuffer.onDidChangeSoftWrapped(callback) + # Extended: Calls your `callback` when the buffer's encoding has changed. + # + # * `callback` {Function} + # + # Returns a {Disposable} on which `.dispose()` can be called to unsubscribe. + onDidChangeEncoding: (callback) -> + @emitter.on 'did-change-encoding', callback + # Extended: Calls your `callback` when the grammar that interprets and # colorizes the text has been changed. Immediately calls your callback with # the current grammar. From 5985175b07f765149a2aace21408273d136215b9 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 28 Oct 2014 15:40:01 -0700 Subject: [PATCH 06/12] :memo: Fix typo --- src/text-editor.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/text-editor.coffee b/src/text-editor.coffee index b0143ea71..1707ae86a 100644 --- a/src/text-editor.coffee +++ b/src/text-editor.coffee @@ -138,7 +138,7 @@ class TextEditor extends Model @emitter.emit 'did-change-encoding', @getEncoding() @subscribe @buffer.onDidDestroy => @destroy() - # TODO: remove these thwne we remove the deprecations. They are old events. + # TODO: remove these when we remove the deprecations. They are old events. @subscribe @buffer.onDidStopChanging => @emit "contents-modified" @subscribe @buffer.onDidConflict => @emit "contents-conflicted" @subscribe @buffer.onDidChangeModified => @emit "modified-status-changed" From a24279d0b92898e0835b61643b3a3a0cfa30ca27 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 28 Oct 2014 16:03:20 -0700 Subject: [PATCH 07/12] :arrow_up: pathwatcher@2.3.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fdb07a2b3..a4660aeea 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "nslog": "^1.0.1", "oniguruma": "^3.0.4", "optimist": "0.4.0", - "pathwatcher": "^2.3.1", + "pathwatcher": "^2.3.2", "property-accessors": "^1", "q": "^1.0.1", "random-words": "0.0.1", From a41b582032381d69356d0338d19d7cab8877b7a8 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 28 Oct 2014 16:03:37 -0700 Subject: [PATCH 08/12] :arrow_up: text-buffer@3.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a4660aeea..8a0ee1752 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "serializable": "^1", "space-pen": "3.8.0", "temp": "0.7.0", - "text-buffer": "^3.3.0", + "text-buffer": "^3.4", "theorist": "^1.0.2", "underscore-plus": "^1.6.1", "vm-compatibility-layer": "0.1.0" From f22e741a9b4b334ef1e90e9e921e4343191949b7 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 28 Oct 2014 16:05:55 -0700 Subject: [PATCH 09/12] Bundle encoding-selector package --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 8a0ee1752..1e9ca0bb8 100644 --- a/package.json +++ b/package.json @@ -82,6 +82,7 @@ "command-palette": "0.27.0", "deprecation-cop": "0.11.0", "dev-live-reload": "0.34.0", + "encoding-selector": "0.2.0", "exception-reporting": "0.20.0", "feedback": "0.33.0", "find-and-replace": "0.141.0", From 4242ac0911e396c70b65f6b59102d49c889cd15d Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 28 Oct 2014 16:25:22 -0700 Subject: [PATCH 10/12] :hammer: Add jschardet license override --- build/tasks/license-overrides.coffee | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/build/tasks/license-overrides.coffee b/build/tasks/license-overrides.coffee index f21c7eee9..2ce570949 100644 --- a/build/tasks/license-overrides.coffee +++ b/build/tasks/license-overrides.coffee @@ -60,3 +60,17 @@ module.exports = ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. """ + 'jschardet@1.1.0': + license: 'LGPL' + source: 'README.md in the repository' + sourceText: """ + JsChardet + ========= + + Port of python's chardet (http://chardet.feedparser.org/). + + License + ------- + + LGPL + """ From e99317520577b2912f1aa8063bfd87044f32b550 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 28 Oct 2014 16:28:12 -0700 Subject: [PATCH 11/12] :lipstick: --- build/tasks/license-overrides.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/build/tasks/license-overrides.coffee b/build/tasks/license-overrides.coffee index 2ce570949..ee1f13479 100644 --- a/build/tasks/license-overrides.coffee +++ b/build/tasks/license-overrides.coffee @@ -60,6 +60,7 @@ module.exports = ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. """ + 'jschardet@1.1.0': license: 'LGPL' source: 'README.md in the repository' From ce8143f8e662f492099741f7e701e6f70da40640 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 29 Oct 2014 10:46:41 -0700 Subject: [PATCH 12/12] Add TextEditor::onDidChangeEncoding spec --- spec/text-editor-spec.coffee | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/spec/text-editor-spec.coffee b/spec/text-editor-spec.coffee index 37f31a4d2..7a6a8e5ff 100644 --- a/spec/text-editor-spec.coffee +++ b/spec/text-editor-spec.coffee @@ -157,6 +157,19 @@ describe "TextEditor", -> expect(observed).toEqual [__filename, undefined] + describe "encoding", -> + it "notifies ::onDidChangeEncoding observers when the editor encoding changes", -> + observed = [] + editor.onDidChangeEncoding (encoding) -> observed.push(encoding) + + editor.setEncoding('utf16le') + editor.setEncoding('utf16le') + editor.setEncoding('utf16be') + editor.setEncoding() + editor.setEncoding() + + expect(observed).toEqual ['utf16le', 'utf16be', 'utf8'] + describe "cursor", -> describe ".getLastCursor()", -> it "returns the most recently created cursor", ->