template.nvim icon indicating copy to clipboard operation
template.nvim copied to clipboard

why '{{_cursor_}}' is needed?

Open mizuirorivi opened this issue 1 year ago • 3 comments

example template is following

struct {{_variableA_}} {
  public:
    {{_variableA_}}();
    ~{{_variableA_}}();
    {{_cursor_}}
  private:
    
};

but, when I remove '{{cursor}}', Error caused by arithmetic with nil value especially, the error is occured at 'template.nvim/lua/template/init.lua:228' the line is here

      cursor_pos[1] = start ~= 0 and cur_line + cursor_pos[1] or cursor_pos[1]

cursor_pos[1] is nil

This is inevitable because there is no {{cursor} However, can't the cursor position default behavior depending on the state before insertion? Or do I need to include {{cursor}}?

mizuirorivi avatar Oct 19 '24 06:10 mizuirorivi

It is from calling expand_expresions(v) within asyncread() I guess

mizuirorivi avatar Oct 19 '24 06:10 mizuirorivi

I'm sorry example use custom variable. truthly example is here

struct {{_variable_}} {
  public:
    {{_variable_}}();
    ~{{_variable_}}();
  private:
    
};

when I use variable of default, but I encountered same error.

mizuirorivi avatar Oct 19 '24 06:10 mizuirorivi

I mean, I just wanted to let you know that this is not because of my custom script.

mizuirorivi avatar Oct 19 '24 06:10 mizuirorivi