Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Fixing #10 - trailing white space should not be deleted by default.
Browse files Browse the repository at this point in the history
  • Loading branch information
ccoenen committed Feb 20, 2015
1 parent e706b22 commit 1a9fdb6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
5 changes: 1 addition & 4 deletions lib/main.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ module.exports =
config:
removeTrailingWhitespace:
type: 'boolean'
default: true
scopes:
'.source.jade':
default: false
default: false
ignoreWhitespaceOnCurrentLine:
type: 'boolean'
default: true
Expand Down
10 changes: 7 additions & 3 deletions spec/whitespace-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe "Whitespace", ->

describe "when the editor is destroyed", ->
beforeEach ->
atom.config.set('whitespace.removeTrailingWhitespace', true)
editor.destroy()

it "unsubscribes from the buffer", ->
Expand Down Expand Up @@ -56,9 +57,6 @@ describe "Whitespace", ->
expect(editor.getText()).toBe 'Some text.\n'

describe "when 'whitespace.removeTrailingWhitespace' is false", ->
beforeEach ->
atom.config.set("whitespace.removeTrailingWhitespace", false)

it "does not trim trailing whitespace", ->
editor.insertText "don't trim me \n\n"
editor.save()
Expand All @@ -76,6 +74,7 @@ describe "Whitespace", ->

describe "when 'whitespace.ignoreWhitespaceOnCurrentLine' is true", ->
beforeEach ->
atom.config.set('whitespace.removeTrailingWhitespace', true)
atom.config.set("whitespace.ignoreWhitespaceOnCurrentLine", true)

it "removes the whitespace from all lines, excluding the current lines", ->
Expand All @@ -87,6 +86,7 @@ describe "Whitespace", ->

describe "when 'whitespace.ignoreWhitespaceOnCurrentLine' is false", ->
beforeEach ->
atom.config.set('whitespace.removeTrailingWhitespace', true)
atom.config.set("whitespace.ignoreWhitespaceOnCurrentLine", false)

it "removes the whitespace from all lines, including the current lines", ->
Expand All @@ -98,6 +98,7 @@ describe "Whitespace", ->

describe "when 'whitespace.ignoreWhitespaceOnlyLines' is false", ->
beforeEach ->
atom.config.set('whitespace.removeTrailingWhitespace', true)
atom.config.set("whitespace.ignoreWhitespaceOnlyLines", false)

it "removes the whitespace from all lines, including the whitespace-only lines", ->
Expand All @@ -110,6 +111,7 @@ describe "Whitespace", ->

describe "when 'whitespace.ignoreWhitespaceOnlyLines' is true", ->
beforeEach ->
atom.config.set('whitespace.removeTrailingWhitespace', true)
atom.config.set("whitespace.ignoreWhitespaceOnlyLines", true)

it "removes the wthiespace from all lines, excluding the whitespace-only lines", ->
Expand Down Expand Up @@ -176,6 +178,7 @@ describe "Whitespace", ->

describe "GFM whitespace trimming", ->
beforeEach ->
atom.config.set('whitespace.removeTrailingWhitespace', true)
atom.config.set("whitespace.ignoreWhitespaceOnCurrentLine", false)

waitsForPromise ->
Expand Down Expand Up @@ -261,6 +264,7 @@ describe "Whitespace", ->

it "does not attempt to remove whitespace when the package is deactivated", ->
atom.packages.deactivatePackage 'whitespace'
atom.commands.dispatch(workspaceElement, 'whitespace:remove-trailing-whitespace')
expect(buffer.getText()).toBe "foo \nbar\t \n\nbaz"

describe "when the 'whitespace:convert-tabs-to-spaces' command is run", ->
Expand Down

0 comments on commit 1a9fdb6

Please sign in to comment.