Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Comments and empty lines inside object definitions cause harrowing comment weirdness #49

Open
maranomynet opened this issue Oct 17, 2018 · 4 comments
Labels

Comments

@maranomynet
Copy link

maranomynet commented Oct 17, 2018

namespace = {
    one: 1,
    // A comment (or empty line) inside an object definition triggers weirdness
    two: 2,
}

becomes this:

// A comment (or empty line) inside an object definition triggers weirdness
namespace = {
    one: 1,
    two: 2,
}

But there's more! 😀

If I remove the comment but leave an empty line:

namespace = {
    one: 1,

    two: 2,
}
mixin() {
    // Comment A
    // Comment B
    some: style;
    // Comment C
    // Comment D
}
selector {
    // Comment E
    // Comment F
    some: style;
    // Comment G
    // Comment H
}

Then this happens:

namespace = {
  one: 1,
  two: 2
};

mixin() {
  // Comment A
  some: style;
} // Comment D

selector {
  // Comment E
  some: style;
}
@ThisIsManta
Copy link
Owner

I'm terribly busy this week. Please spare me sometime to fix this.
I suspect that this bug has just been introduced in the recent release.

@K3TH3R
Copy link

K3TH3R commented Nov 24, 2018

I've noticed as well if I have comments at the end of the file, they'll get removed completely.

@Cactusbone
Copy link

Cactusbone commented Oct 8, 2019

Using command line with selectorSeparator=\n

comments at the end of the file are removed:

div
    border 0
// some comment

comments near selectors get removed also

#id
.class // hello there
span
   border 0

weird also with @media and if/else

@media screen // first comment
  if a
    border 0
  else // second comment
    border 20

gives

@media screen
  if a
    border 0
  else
    border 20 // first comment

Comments near if get moved below

if a //comment
  border 0

gives

if a 
  border 0 //comment

keep comment marker gets removed

/*!
 * Some licence
 */

gets transformed to

/*
 * Some licence
 */

notice the ! that disappeared.


Removal of comments in the middle of a file are also a problem

.someClass

  // todo implement this later

.anotherClass
  border 0

transforms to

.someClass
.anotherClass
  border 0

which generates a completely different css


I'll try adding tests in a MR

@Cactusbone
Copy link

Cactusbone commented Oct 9, 2019

testing @maranomynet example, adding empty lines changes the response until 11 empty lines when no more comments can be seen O_o

2019-10-09_12-16-06

However adding a comment in the middle does not move it up anymore, now it simply disappears

Cactusbone added a commit to F4-Group/stylus-supremacy that referenced this issue Oct 9, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants