FileHeader icon indicating copy to clipboard operation
FileHeader copied to clipboard

file_name inserted in first line

Open gtataranni opened this issue 9 years ago • 4 comments

If {{file_name}} is inserted in the header template, no matter which line, when opening an existing file, the first line is substituted with the line from the header template containing {{file_name}}

gtataranni avatar Jul 06 '16 13:07 gtataranni

could you provide the language you were using and the contents of the header/template file? testing with python, with the template file 2nd line being "# File name: {{file_name}}" did not reproduce the issue.

gillett-hernandez avatar Aug 02 '16 22:08 gillett-hernandez

it was with c++ language files (extensions c/cc/h/hh)

gtataranni avatar Aug 07 '16 12:08 gtataranni

sorry i can't reproduce the issue. my cpp file:

/*
* @Author: gilletthernandez
* @Date:   2016-07-27 22:56:27
* @File name: base.cpp
* @Last Modified by:   gilletthernandez
* @Last Modified time: 2016-08-16 20:06:48
*/
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    cout << "Hello World!" << endl;
    return 0;
}

and my tmpl file "C++.tmpl"

/*
* @Author: {{author}}
* @Date:   {{create_time}}
* @File name: {{file_name}}
* @Last Modified by:   {{last_modified_by}}
* @Last Modified time: {{last_modified_time}}
*/

and the command was just a simple Add Header to an existing file.

gillett-hernandez avatar Aug 17 '16 03:08 gillett-hernandez

I just noticed this issue w/ a custom Python template.

I overrode the default Python template with a simpler one in my User plugins folder (also namedPython.tmpl).

###
# {{file_name}}
#
# Tony Andrys <[email protected]>
###

Ctrl+super+a adds the template to an open file correctly. However, switching to a different file in the editor (or perhaps returning to the initial) seems to trigger the bug.

fileheader-bug

The issue does seem to be related to the file_name variable; replacing {{file_name}} with {{created_time}} eliminates the problem.

tonyandrys avatar Jul 06 '17 21:07 tonyandrys