Snippet not working after 1.32 update


#1

Hi,

I have atom installed on Fedora 26, to the latest version. After the latest update, personalised snippets stopped working. They always worked fine, I had the same snippet file for a long time and I haven’t made any change to it for a while. Is there anything related to the 1.32.1 that could have cause this?

The grammar is being recognised correctly. I don’t get any error or warning.

I’ll put the top part here, it’s a bit large, I use all sorts of snippets:

'.source.c, .source.cpp':
  'std':
    'prefix': 'std'
    'body': 'std::'
  'return':
    'prefix': 'return'
    'body': 'return;'
  'break':
    'prefix': 'break'
    'body': 'break;'
  'doxygen-brief':
    'prefix': 'dbrief'
    'body': "/// \\\\brief "
  'doxygen-parameter':
    'prefix': 'dparam'
    'body': "/// \\\\param "
  'doxygen-returns':
    'prefix': 'dreturns'
    'body': "/// \\\\returns "
  'doxygen-see-also':
    'prefix': 'dsa'
    'body': "/// \\\\sa "
  'doxygen-todo':
    'prefix': 'dtodo'
    'body': "/// \\\\todo "
  'class-template':
    'prefix': 'class'
    'body': """
      class ${1:className}
      {
      public:
      \t~${1:className} ();
      \t${1:className} ();

      private:

      };
    """

#2

Hmm, your snippets are working ok for me in 1.32.1 on Ubuntu 18.04. I copied the snippets to my snippets file, created a test.c and test.cpp file, and then tried a few of the snippets.

So things worked in 1.32.0 but stopped in 1.31.1 for you?


#3

thanks for trying. I am noticing that it works ok in source files (.c, .cpp). The problem is with header files (.h). Strangely enough it seems pretty random behaviour: In the same file it works in some places and it doesn’t work in other places. This happens with most header files. I can’t quite figure out what the pattern or the cause is, it’s all very confusing.


#4

It’s probably based on the scope at the cursor’s position. You can run the command Editor: Log Cursor Scope through the Command Palette (ctrl-shift-p, and start typing the command name). You’ll see a blue notification with a list of CSS selectors. The snippet will only apply if either .source.c or .source.cpp is in the list.


#5

@DamnedScholar Thanks that is very interesting. The source.cpp scope is detected everywhere correctly, but whenever there is also the `comment.block’ scope, the snippets disappear. It seems that it thinks I am within a comment block, where it shouldn’t.


#6

Can you give an example of this @paolotherocker?


#7

This is one example:

class myClass_t
{
public:
	~myClass_t ();

	/// \brief This is the constructor
	myClass_t ();

	
	
	/// \brief Add a tagged value to the output vector
	/// \param value_ The tagged value
	/// \sa outputs
	void addOutput (taggedValue_t const &value_);
	

private:

};

snippets don’t work between the constructor and the method


#8

Ok I think it’s solved with version 1.32.2, I cannot reproduce the issue anymore

thanks


#9

Ok I think it’s solved with version 1.32.2, I cannot reproduce the issue anymore

The team is fixing a number of Tree-sitter related issues in the latest hotfixes so glad this is resolved :+1:

If you run into other issues let us know :v: