From bf644d1a6bf1aca0999b180a44b323f1693d1f8d Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 12 Aug 2016 14:31:07 -0700 Subject: [PATCH] Remove some unnecessary TextEditor accessor methods --- spec/text-editor-registry-spec.js | 30 ++++++++++++++---------------- src/text-editor.coffee | 8 -------- 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/spec/text-editor-registry-spec.js b/spec/text-editor-registry-spec.js index 7181dddf7..ef25d8a33 100644 --- a/spec/text-editor-registry-spec.js +++ b/spec/text-editor-registry-spec.js @@ -377,18 +377,6 @@ describe('TextEditorRegistry', function () { expect(editor.hasAtomicSoftTabs()).toBe(true) }) - it('enables or disables invisible based on the config', function () { - editor.update({showInvisibles: true}) - expect(editor.doesShowInvisibles()).toBe(true) - - atom.config.set('editor.showInvisibles', false) - registry.maintainConfig(editor) - expect(editor.doesShowInvisibles()).toBe(false) - - atom.config.set('editor.showInvisibles', true) - expect(editor.doesShowInvisibles()).toBe(true) - }) - it('sets the invisibles based on the config', function () { const invisibles1 = {'tab': 'a', 'cr': false, eol: false, space: false} const invisibles2 = {'tab': 'b', 'cr': false, eol: false, space: false} @@ -406,6 +394,9 @@ describe('TextEditorRegistry', function () { atom.config.set('editor.invisibles', invisibles1) expect(editor.getInvisibles()).toEqual(invisibles1) + + atom.config.set('editor.showInvisibles', false) + expect(editor.getInvisibles()).toEqual({}) }) it('enables or disables the indent guide based on the config', function () { @@ -445,15 +436,22 @@ describe('TextEditorRegistry', function () { }) it('enables or disables preferred line length-based soft wrap based on the config', function () { - editor.update({softWrapAtPreferredLineLength: true}) - expect(editor.doesSoftWrapAtPreferredLineLength()).toBe(true) + editor.update({ + softWrapped: true, + preferredLineLength: 80, + editorWidthInChars: 120, + softWrapAtPreferredLineLength: true, + }) + expect(editor.getSoftWrapColumn()).toBe(80) + + atom.config.set('editor.softWrap', true) atom.config.set('editor.softWrapAtPreferredLineLength', false) registry.maintainConfig(editor) - expect(editor.doesSoftWrapAtPreferredLineLength()).toBe(false) + expect(editor.getSoftWrapColumn()).toBe(120) atom.config.set('editor.softWrapAtPreferredLineLength', true) - expect(editor.doesSoftWrapAtPreferredLineLength()).toBe(true) + expect(editor.getSoftWrapColumn()).toBe(80) }) it('sets the preferred line length based on the config', function () { diff --git a/src/text-editor.coffee b/src/text-editor.coffee index faad3bb52..75b12f6ad 100644 --- a/src/text-editor.coffee +++ b/src/text-editor.coffee @@ -847,8 +847,6 @@ class TextEditor extends Model Section: File Operations ### - setBackUpBeforeSaving: (@backUpBeforeSaving) -> - doesBackUpBeforeSaving: -> @backUpBeforeSaving # Essential: Saves the editor's text buffer. @@ -2839,9 +2837,6 @@ class TextEditor extends Model # fallback to using the `editor.tabLength` config setting setTabLength: (tabLength) -> @update({tabLength}) - # Returns a {Boolean} indicating whether atomic soft tabs are enabled for this editor. - doesShowInvisibles: -> @showInvisibles - # Enable or disable invisible character substitution for this editor. # # * `showInvisibles` A {Boolean} @@ -2921,8 +2916,6 @@ class TextEditor extends Model setSoftWrapAtPreferredLineLength: (softWrapAtPreferredLineLength) -> @update({softWrapAtPreferredLineLength}) - doesSoftWrapAtPreferredLineLength: -> @softWrapAtPreferredLineLength - setPreferredLineLength: (preferredLineLength) -> @update({preferredLineLength}) getPreferredLineLength: -> @preferredLineLength @@ -2934,7 +2927,6 @@ class TextEditor extends Model # Essential: Gets the column at which column will soft wrap getSoftWrapColumn: -> - scopeDescriptor = @getRootScopeDescriptor() if @isSoftWrapped() if @softWrapAtPreferredLineLength Math.min(@getEditorWidthInChars(), @preferredLineLength)