From d06da3f47046643292c0a451be5ca51c67436a1b Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Thu, 5 May 2016 09:10:36 +0200 Subject: [PATCH] Reset display layer when editor.atomicSoftTabs changes --- spec/text-editor-spec.coffee | 24 ++++++++++++++++++++++++ src/text-editor.coffee | 1 + 2 files changed, 25 insertions(+) diff --git a/spec/text-editor-spec.coffee b/spec/text-editor-spec.coffee index 8f4231323..be24baa01 100644 --- a/spec/text-editor-spec.coffee +++ b/spec/text-editor-spec.coffee @@ -5268,6 +5268,30 @@ describe "TextEditor", -> coffeeEditor.insertText("\n") expect(coffeeEditor.lineTextForBufferRow(2)).toBe "" + describe "editor.atomicSoftTabs", -> + it "skips tab-length runs of leading whitespace when moving the cursor", -> + atom.config.set('editor.tabLength', 4) + + atom.config.set('editor.atomicSoftTabs', true) + editor.setCursorScreenPosition([2, 3]) + expect(editor.getCursorScreenPosition()).toEqual [2, 4] + + atom.config.set('editor.atomicSoftTabs', false) + editor.setCursorScreenPosition([2, 3]) + expect(editor.getCursorScreenPosition()).toEqual [2, 3] + + atom.config.set('editor.atomicSoftTabs', true) + editor.setCursorScreenPosition([2, 3]) + expect(editor.getCursorScreenPosition()).toEqual [2, 4] + + atom.config.set('editor.atomicSoftTabs', false, scopeSelector: '.source.foo') + editor.setCursorScreenPosition([2, 3]) + expect(editor.getCursorScreenPosition()).toEqual [2, 4] + + atom.config.set('editor.atomicSoftTabs', false, scopeSelector: '.source.js') + editor.setCursorScreenPosition([2, 3]) + expect(editor.getCursorScreenPosition()).toEqual [2, 3] + describe ".destroy()", -> it "destroys marker layers associated with the text editor", -> selectionsMarkerLayerId = editor.selectionsMarkerLayer.id diff --git a/src/text-editor.coffee b/src/text-editor.coffee index 9607f3437..54f65ceda 100644 --- a/src/text-editor.coffee +++ b/src/text-editor.coffee @@ -230,6 +230,7 @@ class TextEditor extends Model @scopedConfigSubscriptions = subscriptions = new CompositeDisposable scopeDescriptor = @getRootScopeDescriptor() + subscriptions.add @config.onDidChange 'editor.atomicSoftTabs', scope: scopeDescriptor, @resetDisplayLayer.bind(this) subscriptions.add @config.onDidChange 'editor.tabLength', scope: scopeDescriptor, @resetDisplayLayer.bind(this) subscriptions.add @config.onDidChange 'editor.invisibles', scope: scopeDescriptor, @resetDisplayLayer.bind(this) subscriptions.add @config.onDidChange 'editor.showInvisibles', scope: scopeDescriptor, @resetDisplayLayer.bind(this)