guiguan / file-header

FileHeader for Atom
https://atom.io/packages/file-header
Other
31 stars 21 forks source link

Adds header with every save #47

Closed eng618 closed 6 years ago

eng618 commented 6 years ago

PR #44 seemed to take a step in the right direction...but now when I "enable auto update" it adds subsequent headers with each save.

i.e. if I save a file 3 times it adds 3 headers.

// header

// header

// header

// code ...
guiguan commented 6 years ago

Can you try with latest version of Atom?

naiz0 commented 6 years ago

since the last version, you published yesterday, i can't save a file. when i disable "file-header" saving a file is no problem.

eng618 commented 6 years ago

@guiguan I'm on 1.22.0-beta0

guiguan commented 6 years ago

Strange. I am on 1.22.0-beta0, and it works fine. Does this behaviour happen for new file as well?

TheOneKevin commented 6 years ago

I'm on 1.21.0 and my file failed to save. Upon updating to 1.22.0-beta0, it still doesn't save. When manually pressing the "Update Header" button, this error pops up: "Uncaught TypeError: Cannot read property 'undoStack' of undefined"

eng618 commented 6 years ago

@guiguan yes, same behaviour with new files... On first creation of new file there are 2 headers and add a new one with each save

guiguan commented 6 years ago

@TheCool1Kevin try #49

guiguan commented 6 years ago

@ENG618 what kind of files were you working on? js? Can you share a snippet and let me see if I can recreate the problem on my end?

guiguan commented 6 years ago

@naiz0 try #49

naiz0 commented 6 years ago

works now for linux and windows. thanks!

eng618 commented 6 years ago

yes .js files and you can do or .sh are the only ones I have tested on. You can use any new or existing file and it should exhibit the same behavior.

The enable auto update, is the only checkbox causing the issue. It applies okay on new files and works fine if that update one is not checked.

I also do have custom header templates that are being used...not sure if that might have something to do with it at all since possible the default template is not being present in the update check and then adds a new header.

guiguan commented 6 years ago

@ENG618 Custom header should work fine. I am using mine as well. I couldn't reproduce your error on my Atom.

Do you have those @ in your custom header templates?

eng618 commented 6 years ago

@guiguan no there are no @ in my template...it's just plain text.

C.tmpl looks like this:

/**
 * Licensed Materials - Property of Example 
 *
 * (C) Copyright Example Corporation 2017
 *
 * Other text here
 */
eng618 commented 6 years ago

Just tested with:

/**
 * @Licensed Materials - Property of Example 
 *
 * @(C) Copyright Example Corporation 2017
 *
 * @Other text here
 */

and

/**
 * @Licensed Materials - Property of Example 
 * @
 * @(C) Copyright Example Corporation 2017
 * @
 * @Other text here
 */

same result

eng618 commented 6 years ago

If I'm not using custom templates, it seems to work fine and only add it once...

guiguan commented 6 years ago

@ENG618 I see your problem now. file-header needs two @ for the auto-update's regex to work: https://github.com/guiguan/file-header/blob/master/lib/file-header.coffee#L279. So in your case, you need to keep at least two @ for {{last_modified_by}} and {{last_modified_time}}:

 * @Last author:   {{last_modified_by}}
 * @Last timestamp: {{last_modified_time}}
guiguan commented 6 years ago

Closing this problem now. @ENG618 let me know if you are still suffering from this

ts33kr commented 6 years ago

Unfortunately I am suffering from the same issue. I do too have a custom template that does NOT use @.

eng618 commented 6 years ago

would be nice if I didn't have to have those @ in there. You could simply check against the template to see if those chars match what is in there.