From 6ae088386da5162a5bfae9f81c52ee7f01c8e5fa Mon Sep 17 00:00:00 2001 From: Nasy Date: Thu, 2 Aug 2018 23:01:13 +0800 Subject: [PATCH] Add feature: #53 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. --- lib/file-header.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/file-header.coffee b/lib/file-header.coffee index 6457c34..367a69e 100644 --- a/lib/file-header.coffee +++ b/lib/file-header.coffee @@ -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') @@ -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]