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

Fixing #10 - trailing white space should not be deleted by default. #59

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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