Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

Code sometimes improperly marked as comment #7256

Closed

Description

@adamreisnz

Sometimes, when copy/pasting some code around with comments, I notice that part of my code becomes improperly marked as comments. You can see it happened here, and it becomes normal again when you play around with the comment above it:

ex

Unfortunately, I have not yet found out how it can consistently be reproduced, but I've seen it happen at least 5-6 times already.

I suspect though that it has to do with comment blocks starting with /*. As you can see in the screen recording, the marking seems to end at the */ in the path definition, so it looks as if it's thinking the code above it is part of a comment block still.

This is on Max OS X, Atom 0.209.

Activity

  1. changed the title [-]Code sometimes improperly marked as comments[/-] [+]Code sometimes improperly marked as comment[/+] on Jun 12, 2015
  2. mnquintana commented on Jun 12, 2015

    @mnquintana
    Contributor
  3. adamreisnz commented on Jun 12, 2015

    @adamreisnz
    Author

    I don't think it's only javascript related, I recall seeing it happen in CSS as well. Is that possible?

  4. mnquintana commented on Jun 12, 2015

    @mnquintana
    Contributor

    Can you reproduce this in safe mode? (atom --safe)

  5. adamreisnz commented on Jun 12, 2015

    @adamreisnz
    Author

    Well, as I said, I haven't found a way to reproduce it yet consistently, but once it happens again I will try to analyze what I did and see if I can reproduce it.

  6. adamreisnz commented on Sep 25, 2015

    @adamreisnz
    Author

    @mnquintana I have found a way to reproduce it consistently, see attached screencast:

    ss

    It appears to happen when a doc block comment is started and then completed via code completion.

    When you enter the first few characters (/*), the trailing code is marked as a comment, because there's no comment ending found (*/).

    However, once the code completion is triggered and the comment ending is inserted, the rest of the code remains flagged as a comment and does not get updated.

    Hope this helps.

  7. adamreisnz commented on Feb 10, 2016

    @adamreisnz
    Author

    @benogle this issue also has consistent reproduction steps now, can you remove the needs reproduction label? Unless you need more information, I'm happy to help. Still happens to me occasionally.

  8. benogle commented on Feb 10, 2016

    @benogle
    Contributor

    Sure. This seems like a language-javascript issue, no?

  9. adamreisnz commented on Feb 10, 2016

    @adamreisnz
    Author

    Thanks. I'm pretty sure it also happened to me in SCSS files once or twice, so not sure which package is responsible. It's not like the language detects it wrong, I think it's that the language detects it a split second before the comment is completed by the auto completer, and then never updates it afterwards.

  10. winstliu commented on Feb 10, 2016

    @winstliu
    Contributor

    @adambuczynski How are you triggering autocompletion for the comment block?

  11. adamreisnz commented on Feb 10, 2016

    @adamreisnz
    Author

    This is my snippet for the code block:

    '.source':
        'Comment block':
            'prefix': '/*'
            'body': '''
                /**
                 * ${1:Comment}
                 */
            '''

    And it's triggered by /* + tab

  12. adamreisnz commented on Feb 10, 2016

    @adamreisnz
    Author

    @50Wliu can you try with the following code? This works consistently for me:

    function() {
    
      <insert comment here>
    
      //Comment
      return test;
    }

    This will turn the line return test; into a comment, after you tab complete the snippet.
    The following also works:

    function() {
    
      <insert comment here>
    
      return test;
    }

    Behaviour:

    ss

    This is with language-javascript, Atom 1.5.0 on OS X.

  13. winstliu commented on Feb 10, 2016

    @winstliu
    Contributor

    Still nothing. I noticed you're using [email protected] though, while the latest version is 0.110.0.

    I would try to reproduce in safe mode but I don't think snippets.cson gets loaded in that scenario.

  14. adamreisnz commented on Feb 10, 2016

    @adamreisnz
    Author

    I was using a development version of the package, as I had made some changes to it. Removed this now, and on 0.105.0 now (version bundled with 1.5.0 atom I suppose).

    The issue is still reproducible though. Perhaps it only occurs on Mac due to some differences in keyboard input handling? Is there someone else on the dev team with a Mac that could check this behaviour?

  15. liatreis commented on Feb 10, 2016

    @liatreis

    Same issue for me on Windows 7, so not for Mac only.

  16. adamreisnz commented on Feb 16, 2016

    @adamreisnz
    Author

    Here's another demo of it happening inside a describe test block

    ss

    I think the issue has to do with the fact that maybe the code highlighting isn't run again after the auto completed code is inserted, making the highlighter think that the comment was never closed, hence never un-marking the code from being a comment. Is that a possibility?

  17. adamreisnz commented on Jun 6, 2016

    @adamreisnz
    Author

    In case anyone wants to reproduce, this is the snippet I use that's causing the issue:

    '.source':
        'Comment block':
            'prefix': '/*'
            'body': '''
                /**
                 * ${1:Comment}
                 */
            '''
  18. Ben3eeE commented on Jun 8, 2016

    @Ben3eeE
    Contributor

    I did some investigating and managed to figure out when this happens I think, it has to do with whitespace/invisibles/indentation on all the lines. I did not manage to reproduce when copy/pasting as the original post stated but didn't test much with copy/pasting.

    Example, if you expand this snippet in a js file it reproduces, this is with the default js snippet for block comments no custom snippets needed.

    function a(b) {
        /**
    <NON INDENTED EMPTY LINE WITH ONLY A CRLF OR LF CHARACTER>
        var c = b +15;
        return c;
    }
    

    But not if you expand this:

    function a(b) {
        /**
        <INDENTED EMPTY LINE>
        var c = b +15;
        return c;
    }
    

    And not if you expand this:

    function a(b) {
        /**
    <NON INDENTED EMPTY LINE WITH ONLY A CRLF OR LF CHARACTER>
            var c = b +15;
        return c;
    }
    

    Also not if you expand this:

    function a(b) {
    /**
    <NON INDENTED EMPTY LINE WITH ONLY A CRLF OR LF CHARACTER>
    var c = b +15;
    return c;
    }
    

    Also not if you expand this:

    function a(b) {
        /**
    <NON INDENTED EMPTY LINE WITH ONLY A CRLF OR LF CHARACTER>
            <TABBED LINE PAST THE SNIPPET LINE>
        var c = b +15;
        return c;
    }
    

    But it does if you expand this:

    function a(b) {
        /**
    <NON INDENTED EMPTY LINE WITH ONLY A CRLF OR LF CHARACTER>
    <NON INDENTED EMPTY LINE WITH ONLY A CRLF OR LF CHARACTER>
        <TABBED LINE NOT PAST THE SNIPPET LINE>
        <TABBED LINE NOT PAST THE SNIPPET LINE>
        var c = b +15;
        return c;
    }
    

    I am on Windows 7 with Atom 1.8.0, I can maybe test the latest master later but I don't have it built now because I am on the node4 npm3 branch.

  19. adamreisnz commented on Aug 21, 2017

    @adamreisnz
    Author

    I don't think this is happening anymore, so I'm going to close this issue. Must have gotten fixed somewhere along the line.

  20. lock commented on Mar 31, 2018

    @lock

    This issue has been automatically locked since there has not been any recent activity after it was closed. If you can still reproduce this issue in Safe Mode then please open a new issue and fill out the entire issue template to ensure that we have enough information to address your issue. Thanks!

  21. locked and limited conversation to collaborators on Mar 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions