mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-22 08:28:41 +03:00
Leave Markdown files alone
This commit is contained in:
parent
1ccf026a83
commit
4fc7e1a9d5
@ -4,13 +4,14 @@ module.exports =
|
||||
|
||||
configDefaults:
|
||||
ensureSingleTrailingNewline: true
|
||||
ignoredGrammars: ["GitHub Markdown"]
|
||||
|
||||
whitespaceBeforeSave: (editSession) ->
|
||||
buffer = editSession.buffer
|
||||
buffer.on 'will-be-saved', ->
|
||||
return if editSession.getGrammar().name in config.get("whitespace.ignoredGrammars")
|
||||
buffer.transact ->
|
||||
buffer.scan /[ \t]+$/g, ({replace}) -> replace('')
|
||||
|
||||
if config.get('whitespace.ensureSingleTrailingNewline')
|
||||
if buffer.getLastLine() is ''
|
||||
row = buffer.getLastRow() - 1
|
||||
|
@ -86,3 +86,28 @@ describe "Whitespace", ->
|
||||
editor.getBuffer().save()
|
||||
expect(editor.getText()).toBe "foo\n"
|
||||
expect(editor.getCursorBufferPosition()).toEqual([0,3])
|
||||
|
||||
describe "whitespace.ensureSingleTrailingNewline config", ->
|
||||
[originalConfigValue] = []
|
||||
grammar = null
|
||||
|
||||
beforeEach ->
|
||||
originalConfigValue = config.get("whitespace.ignoredGrammars")
|
||||
expect(originalConfigValue).toEqual ["GitHub Markdown"]
|
||||
spyOn(syntax, "addGrammar").andCallThrough()
|
||||
atom.activatePackage("gfm")
|
||||
expect(syntax.addGrammar).toHaveBeenCalled()
|
||||
grammar = syntax.addGrammar.argsForCall[0][0]
|
||||
|
||||
afterEach ->
|
||||
config.set("whitespace.ignoredGrammars", originalConfigValue)
|
||||
config.update()
|
||||
|
||||
it "parses the grammar", ->
|
||||
expect(grammar).toBeDefined()
|
||||
expect(grammar.scopeName).toBe "source.gfm"
|
||||
|
||||
it "leaves Markdown files alone", ->
|
||||
editor.insertText "foo \nline break!"
|
||||
editor.getBuffer().save()
|
||||
expect(editor.getText()).toBe "foo \nline break!"
|
||||
|
Loading…
Reference in New Issue
Block a user