atom / snippets

Atom snippets package
MIT License
205 stars 100 forks source link

Multi-line snippet not indenting properly #213

Closed ffxsam closed 6 years ago

ffxsam commented 8 years ago

Snippet indentation is incorrect. I have the following snippet:

'.source.js':
  'React method':
    'prefix': 'rm',
    'body': """
    $1 = ($2) => {
      $3
    };
    """

I open a .js file and type "rm" then hit tab and fill it in.

Expected behavior: [What you expected to happen]

Expected result: (e.g.):

  testMethod = () => {
    this.doSomething();
  };

Actual behavior: [What actually happened]

  testMethod = () => {
     this.doSomething();
   };

Versions

You can get this information from executing atom --version and apm --version at the command line. Also, please include the OS and what version of the OS you're running.

Atom    : 1.10.2
Electron: 0.37.8
Chrome  : 49.0.2623.75
Node    : 5.10.0
apm  1.12.5
npm  3.10.5
node 4.4.5
python 2.7.10
git 2.9.3

Mac OS 10.11.6
ffxsam commented 8 years ago

Updated post to include more details.

xykivo commented 8 years ago

I'm also seeing this issue on 1.10.

However it only happens when the first word in a line is tab stop. So the following snippet will have wrong indentation:

  'C++ constructor declaration':
    'prefix': 'ctrd'
    'body': """
      /// Construct a ${1:'class'} instance
      ${1:'class'}(${2:'arguments'}) noexcept;$0
    """
    'description': 'C++ constructor declaration'

While this snippet will behave correctly

  'C++ class':
    'prefix': 'cls'
    'body': """
      /// ${2:'doc'}
      class ${1:'class'} {
      $0
      }; // end of class ${1:'class'}
    """
    'description': 'C++ class declaration'
ffxsam commented 7 years ago

This is still a problem. I now have two snippets that don't indent properly (on Babel JS filetypes).

'.source.js':
  'React Method':
    'prefix': 'rmethod',
    'body': """
      $1 = ($2) => {
        $3
      };
    """
  'React PropType':
    'prefix': 'rptype',
    'body': """
      /*
       * $1
       */
       $2: PropTypes.$3
    """

The issue seems to be with a $ argument at the beginning of a line.

inwardmovement commented 7 years ago

I have the same problem.

inwardmovement commented 7 years ago

this issue has not been solved in one year ? will it be some time so we can use Atom properly ?

ffxsam commented 7 years ago

@50Wliu Any updates on this?

50Wliu commented 7 years ago

No. Contributions are gladly appreciated.

mikeerickson commented 7 years ago

@50Wliu oft to complain, but slow to contribute. Sums up OSS in a nutshell. I however appreciate your efforts in making snippets available in Atom!

ffxsam commented 7 years ago

@mikeerickson Pardon me, but I was filing an issue and following up. Not “complaining.” And some of us are full-time devs working 60-80 hours per week, with no time for OSS contributions.

mikeerickson commented 7 years ago

@ffxsam I am a full time developer myself, working 6 days/week, 12-15 hour days... Don't need to battle about working hours.

Further the complaint was not from you, but rather @inwardmovement "this issue has not been solved in one year? will it be some time so we can use Atom properly ?"

Atom works properly, just has an issue with expanding a snippet.

lee-dohm commented 7 years ago

Let's keep things classy here everyone. We expect everyone to follow the Atom Code of Conduct in their interactions.

ffxsam commented 7 years ago

@mikeerickson I agree, people should keep their issues neutral and not make demands of OSS developers. But we shouldn't make assumptions about people's time availability to make contributions.

inwardmovement commented 7 years ago

I agree my message was a bit harsh... please forgive me. I just found it strange that this bug (that totally prevents me from migrating from Notepadd++ to Atom, for example) which seems quite important to me (I agree it is totally personal) was not yet solved. I thought Atom/GitHub community was big and full of passionate and available coders to do "the job" in the minute, but now I realize it is maybe not so simple :) So my bad, this bug will be solved when someone has time to do so and that's it. Maybe I will take a look at it when I have finished other projects, although I don't know anything at Atom coding for now, we never know... Have a good day everyone.

edit: if someone suspects the bug to "take place" in this file or that file, feel free to mention it so I would have a place to start. Sorry for my bad english I hope you understand.

ffxsam commented 7 years ago

@inwardmovement Thanks for that :) not to mention, this is not a critical bug either, and there are likely dozens of other things that warrant more attention.

50Wliu commented 6 years ago

Will be fixed by #245. I need to figure out why though and then add a spec.

50Wliu commented 6 years ago

Ah, I see what the problem was. Indentation was happening after the snippet was inserted. Since tab stops are removed, it was picking up the space in front of the = as extra indentation. But in #245 indentation happens before the snippet is inserted.

buggymcbugfix commented 6 years ago

Having the same issue. Thanks for you efforts :)