Skip to content

Commit

Permalink
Add feature: guiguan#53
Browse files Browse the repository at this point in the history
Add feature: allow update of the header with not only  "@" but also other char.

- `#` for languages like Python
- `*` for languages like C
- `-` for languages like Haskell
- `;` for languages like lisp

Thought it works well on my Mac, I am still not sure whether it would cause any problem or not.
  • Loading branch information
nasyxx authored Aug 2, 2018
1 parent 8d543ab commit 6ae0883
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/file-header.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ module.exports = FileHeader =
# the corresponding header template is presented
hasHeader: (editor, buffer, headerTemplate) ->
# these placeholder preambles are used as anchor points in source code scanning
if !(preambles = headerTemplate.match(/@[^:]+:/g))
if !(preambles = headerTemplate.match(/[@-#;\*\\][^:]+:/g))
return false
preambles = preambles.map(@escapeRegExp)
re = new RegExp(preambles.join('|'), if atom.config.get('file-header.ignoreCaseInTemplateField', scope: (do editor.getRootScopeDescriptor)) then 'gi' else 'g')
Expand All @@ -276,7 +276,7 @@ module.exports = FileHeader =

updateField: (editor, placeholder, headerTemplate, buffer, newValue) ->
escaptedPlaceholder = @escapeRegExp(placeholder)
re = new RegExp(".*(@[^:]+:).*#{ escaptedPlaceholder }.*(?:\r\n|\r|\n)", 'g')
re = new RegExp(".*([@-#;\*\\][^:]+:).*#{ escaptedPlaceholder }.*(?:\r\n|\r|\n)", 'g')
# find anchor point and line in current template
while match = re.exec(headerTemplate)
anchor = match[1]
Expand Down

0 comments on commit 6ae0883

Please sign in to comment.