mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
modify whitespace replace fn directly
This commit is contained in:
@@ -4,14 +4,18 @@ 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('')
|
||||
regex = null
|
||||
|
||||
buffer.scan /[ \t]+$/g, ({match, replace}) ->
|
||||
# GFM permits two whitespaces at the end of a line--trim anything else
|
||||
unless editSession.getGrammar().scopeName = "scope.gfm" and match[0].length == 2
|
||||
replace('')
|
||||
|
||||
if config.get('whitespace.ensureSingleTrailingNewline')
|
||||
if buffer.getLastLine() is ''
|
||||
row = buffer.getLastRow() - 1
|
||||
|
||||
Reference in New Issue
Block a user